From patchwork Tue Jul 7 12:58:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11648537 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 12BB7912 for ; Tue, 7 Jul 2020 12:59:52 +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 DF75D20708 for ; Tue, 7 Jul 2020 12:59:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cfr9lD/R"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ad7XXos1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF75D20708 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=oxGyIOMp0Ev4UnIn3nBGj0MhP5wbK8i9Skx3cSdTOmI=; b=cfr9lD/RLeEKSexQXXHjXKkJG rwIcqh2VJpXCvfhbr/gx95+NKlP6WTX9GFGEdhYUKcBxuduzv/f0yihjc5+v3iWv+KEI1nlVtIH8b a5jn788bAYjf/WjvTfocGrjfwAi9a7YtPOqDNZvWqltsRouHi8IhlV6PQYBbnBkMabz3rUaZrEasF PhtHCbe4kVzjz1wxELjbsajJlu8msW+cBr1bWJMs/zaAZXNOgoTxFsKztJNgxj+eAdXB/+3P2PCSx 2vsonVnianXcr+1KmOH7xtoCB8O1M4N8REzQocaysjHm3hZfC5+f2PpQRtQA04xLQsTsWd/1S5NoW 7buaKX+Bg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnBA-0006Z5-Eh; Tue, 07 Jul 2020 12:58:32 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnB0-0006Vx-Gh for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2020 12:58:24 +0000 Received: by mail-lj1-x241.google.com with SMTP id t25so45165666lji.12 for ; Tue, 07 Jul 2020 05:58:22 -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=JmH1BfPiU4RoSWuHQPEJ8Sx4+RN7bhXBUvJ2uLAr9qM=; b=Ad7XXos1cMmY+GKjq/D9UtSBmDNPOeVXkEk3XQ8wQl0QlkUWtCwInOmjZmoDIncBHb XK6+h7K+uqUHqZXaTO/qeFFYBZ/TGnH2PC2189v/S6CCjKuMkMGXkOhaIB+GjZsRkXGP sZlwnSie+aPey2AKnh2JAKCuFh3oGUOu0n2/RvUWQQHtCbS+yFnqUaLPv6igWPkwW4Oj 6MnRpJOehFo5cmYc6/vsfoQuy25/s4gsoreVtAlkV5pLjTpOhJxullGUTeW+KgwGcki6 vEDYWNZL4eOuJ4W7a8oOxNgk29NhvZA+uOHbJI5AmMwuTcfOIe8DqXORy5X+/1bnSSOl e8yA== 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=JmH1BfPiU4RoSWuHQPEJ8Sx4+RN7bhXBUvJ2uLAr9qM=; b=UGGimazVo1BdQFncAJESqfru9TrMtDzvH0XdbMU3mfF3uYqN0kG5769rb2DUwH5vjz FPNXmTItWwMl2m86RTPUd84uBrc0Lo7apbYO+CY/CIRlvG/DHDoEx5gOctQQ+XqDP7R7 IusLSYq7byqlBIzOukWITPB54ZvccQy+QNqw9CqqzUbBFa1hsYrNjf3zKgYWC1M51kFD HL5cKMK8Bod7LxjWK9EnkeDxwXAc48Z5u8Tq/PfnbJ1Q3AHR0lTg1obbnXcer/3sAs3u IPP7sq51DAaftS2aZwprQDHyLeS2lNP9RvZu7CKH9A37JG7UE1m0TyMtBKzcow6Q8AfR pWcQ== X-Gm-Message-State: AOAM533LaVoToADaOvdLgj3qFqM2U0sC809wt4/BKvmx9C5ReimvJZZT TNKOXjuYmYwiS5xOqPI7ceNABw== X-Google-Smtp-Source: ABdhPJzUlqKwp5fDTuJIhcklcQOJEemZfGYMUbMkILw8e1U/ymMGmHmpI3jEkHFPEWctxqwO/X56vg== X-Received: by 2002:a05:651c:21a:: with SMTP id y26mr14747466ljn.106.1594126701205; Tue, 07 Jul 2020 05:58:21 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 05:58:20 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 1/5] cpuidle: psci: Split into two separate build objects Date: Tue, 7 Jul 2020 14:58:00 +0200 Message-Id: <20200707125804.13030-2-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_085822_580270_BD26BFC7 X-CRM114-Status: GOOD ( 12.48 ) 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:241 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 The combined build object for the PSCI cpuidle driver and the PSCI PM domain, is a bit messy. Therefore let's split it up by adding a new Kconfig ARM_PSCI_CPUIDLE_DOMAIN and convert into two separate objects. Reviewed-by: Lina Iyer Reviewed-by: Sudeep Holla Signed-off-by: Ulf Hansson --- drivers/cpuidle/Kconfig.arm | 10 ++++++++++ drivers/cpuidle/Makefile | 5 ++--- drivers/cpuidle/cpuidle-psci.h | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm index 51a7e89085c0..0844fadc4be8 100644 --- a/drivers/cpuidle/Kconfig.arm +++ b/drivers/cpuidle/Kconfig.arm @@ -23,6 +23,16 @@ config ARM_PSCI_CPUIDLE It provides an idle driver that is capable of detecting and managing idle states through the PSCI firmware interface. +config ARM_PSCI_CPUIDLE_DOMAIN + bool "PSCI CPU idle Domain" + depends on ARM_PSCI_CPUIDLE + depends on PM_GENERIC_DOMAINS_OF + default y + help + Select this to enable the PSCI based CPUidle driver to use PM domains, + which is needed to support the hierarchical DT based layout of the + idle states. + config ARM_BIG_LITTLE_CPUIDLE bool "Support for ARM big.LITTLE processors" depends on ARCH_VEXPRESS_TC2_PM || ARCH_EXYNOS || COMPILE_TEST diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index f07800cbb43f..26bbc5e74123 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile @@ -21,9 +21,8 @@ obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o obj-$(CONFIG_ARM_EXYNOS_CPUIDLE) += cpuidle-exynos.o obj-$(CONFIG_ARM_CPUIDLE) += cpuidle-arm.o -obj-$(CONFIG_ARM_PSCI_CPUIDLE) += cpuidle_psci.o -cpuidle_psci-y := cpuidle-psci.o -cpuidle_psci-$(CONFIG_PM_GENERIC_DOMAINS_OF) += cpuidle-psci-domain.o +obj-$(CONFIG_ARM_PSCI_CPUIDLE) += cpuidle-psci.o +obj-$(CONFIG_ARM_PSCI_CPUIDLE_DOMAIN) += cpuidle-psci-domain.o obj-$(CONFIG_ARM_TEGRA_CPUIDLE) += cpuidle-tegra.o obj-$(CONFIG_ARM_QCOM_SPM_CPUIDLE) += cpuidle-qcom-spm.o diff --git a/drivers/cpuidle/cpuidle-psci.h b/drivers/cpuidle/cpuidle-psci.h index 7299a04dd467..ac8170684d4f 100644 --- a/drivers/cpuidle/cpuidle-psci.h +++ b/drivers/cpuidle/cpuidle-psci.h @@ -8,7 +8,7 @@ struct device_node; void psci_set_domain_state(u32 state); int __init psci_dt_parse_state_node(struct device_node *np, u32 *state); -#ifdef CONFIG_PM_GENERIC_DOMAINS_OF +#ifdef CONFIG_ARM_PSCI_CPUIDLE_DOMAIN struct device __init *psci_dt_attach_cpu(int cpu); #else static inline struct device __init *psci_dt_attach_cpu(int cpu) { return NULL; } From patchwork Tue Jul 7 12:58:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11648541 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 8267692A for ; Tue, 7 Jul 2020 13:00:05 +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 5B58320773 for ; Tue, 7 Jul 2020 13:00:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZoW1ziDC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WcTZPDyr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B58320773 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=CfnPVa/u70Ayn9LNiFe8K/rZdvyA3WNs35V+U/2C9WA=; b=ZoW1ziDCDyJfqaJtMbwf6RN6k SOXA2nBVbRCYWctpaUxERh1yCJ7JBJmTHmPuNnNHf+TOSqKE+CVm5izTmBkk2Kn8TVIvaOsBbxo7l RMLKYrbP19QLQVg0WiSJ48rKKhCAucohqGVAHgOLy9F3NCgOPa/ux9DzAWThuXnWcjBp9AkzDAmtT V7ZWxnEesFWS7zv8jUe06JcGz3LDcJOe/L7+OWt5W61BgDsbMIDhTaShcA8KnZ1Xzkf7vJumutakL zlnJDiVQ0FciYkBoX0B9jN5/mXyfx4kzbakiAKiitCOrWGGu0sY+QhyrwIKvuG4jxoHRshaufLc+o yeCr2liaQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnBI-0006cr-6d; Tue, 07 Jul 2020 12:58:40 +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 1jsnB2-0006We-FK for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2020 12:58:26 +0000 Received: by mail-lj1-x244.google.com with SMTP id q4so14038002lji.2 for ; Tue, 07 Jul 2020 05:58:24 -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=Tyb4FTg+dS/M/U030tOYrYBkxinzi9TyZY+2pXYSj8s=; b=WcTZPDyrGuD+JpLr2CvFSOW4wI/84AB9XBsPM+jNP55/QXFFMDJ2Kcuad7JKSuEgl4 CMsJcDQJheQ23rJe96pFp9zvexdXKEVqmJE+BhjbytMKWA3ME0ZHKt6RLTMMacnHJqX2 eHz9Jr/J9Itm7q4oL7NVLhg9l448S2Q49iTD4WdSJCSYCeU5QUE0K3iXcaJ0Y2WYHFGZ XQj2KfRpp0yZshd2s60tgduYEi8cCEBXVk/68tYWIKGTQCdf3nT3UUM+49atzgZzQd/F NEWIC0yJKMlERT7u2126WmBfK+sVr1OqaCYc11UQHPCZl/pL+tJtV+RipTMslbw9Rv7W GhPg== 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=Tyb4FTg+dS/M/U030tOYrYBkxinzi9TyZY+2pXYSj8s=; b=AO/ezyrU1Xw7b5nLO+LGdCBgK0KKaY/y5tgRUF7gcy9RqyMfWLuVtYbXtggRqnb9jb 6ee2XEa9UPA8mi2bsSpDSKcyfU2cuXgWdrqTpN8m78lBremqfFbSv68RLH2tUTnaAcua o4scWpxXVRLVTpjrqw/dLVXFqqfaTUPFN/yb6udbIckrg8bWELbWD+X6OFnpuZileOXy 1nO4g/aBvVElqCpCEiJnQI9httPTL4Xw2LHImHviCdgXCahv0h8VGfDSvnlR1fy8Hfa0 Ue4/gjFNvMnstlaMQZBiXBIy7vxUxmyLBo6Mphk3p+0Q3N2JujB8eWq1FFB/tMTJeTfV 3+3Q== X-Gm-Message-State: AOAM530YTl8pnQyzFP9SlkuozT6UH3HRLUuYj3va5AIIpIZqAzR2cU0Z CnKT7yiNsZ8lcz0mcmbWh7HCiA== X-Google-Smtp-Source: ABdhPJylq0jjpwH2fsuo8vkN+Gf9ZYpUxI0iRGTwMhIxlrERcqaj5/+hQ1rGx4VxvHtG/4ViNKkMrA== X-Received: by 2002:a2e:9a8d:: with SMTP id p13mr6597746lji.36.1594126703088; Tue, 07 Jul 2020 05:58:23 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 05:58:21 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 2/5] cpuidle: psci: Fail cpuidle registration if set OSI mode failed Date: Tue, 7 Jul 2020 14:58:01 +0200 Message-Id: <20200707125804.13030-3-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_085825_382440_70B6ACDC X-CRM114-Status: GOOD ( 12.84 ) 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 Currently we allow the cpuidle driver registration to succeed, even if we failed to enable the OSI mode when the hierarchical DT layout is used. This means running in a degraded mode, by using the available idle states per CPU, while also preventing the domain idle states. Moving forward, this behaviour looks quite questionable to maintain, as complexity seems to grow around it, especially when trying to add support for deferred probe, for example. Therefore, let's make the cpuidle driver registration to fail in this situation, thus relying on the default architectural cpuidle backend for WFI to be used. Reviewed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index 423f03bbeb74..f07786aad673 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -26,7 +26,6 @@ struct psci_pd_provider { }; static LIST_HEAD(psci_pd_providers); -static bool osi_mode_enabled __initdata; static int psci_pd_power_off(struct generic_pm_domain *pd) { @@ -272,7 +271,6 @@ static int __init psci_idle_init_domains(void) goto remove_pd; } - osi_mode_enabled = true; of_node_put(np); pr_info("Initialized CPU PM domain topology\n"); return pd_count; @@ -293,9 +291,6 @@ struct device __init *psci_dt_attach_cpu(int cpu) { struct device *dev; - if (!osi_mode_enabled) - return NULL; - dev = dev_pm_domain_attach_by_name(get_cpu_device(cpu), "psci"); if (IS_ERR_OR_NULL(dev)) return dev; From patchwork Tue Jul 7 12:58:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11648545 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 512A6912 for ; Tue, 7 Jul 2020 13:00:13 +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 1BA4820708 for ; Tue, 7 Jul 2020 13:00:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="K/LSm9XD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Hv99sK4G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BA4820708 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=lTp/4FqKG5Cb7A99n3w1dqWF65j3Z9H7LpjbL3cUMjA=; b=K/LSm9XDx9jd6JHa64j1mPj56 8bLvJOKwLDsyqf0+UJ24F3SDHmHa7cG0ZdD97xCt+4eh/szILQv1hsvsZz7ROpzZHjQ3n3j56K4ho Gcs51b0xt8PM4VwUfJ5pfQUkoFoC0hPCx64wBFF/nu8e58IBYz1avbbtH0V2fFLA4SR6yVfTGFgt3 mRXiY4MzIiQTS9GJOFg4XjQEDPSGqPol5Ypa7ZrAQJYEc4D9DisQpU34sFSFkUbrgnWmBUdLTX2jV O4wGSnQ1uJynAiIUjCVG1XeFLXghOOiCtGtv/UWWQwLgx3mmsJjf49jBdcJgrH30NHGlQBB/uhtb3 a4zKvDwAQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnBO-0006fP-4A; Tue, 07 Jul 2020 12:58:46 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnB4-0006XI-Jb for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2020 12:58:30 +0000 Received: by mail-lf1-x143.google.com with SMTP id c11so24631001lfh.8 for ; Tue, 07 Jul 2020 05:58:26 -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=RKH4B95PNXl3C5rwhY+t4SQh2JqyVx0OlVSkqz5kPHs=; b=Hv99sK4GX66OYmzNN/mEh9xlA+DDTCwCLlBG5kGfxyjuko2fDS6BSlh+9GHNw8ogI/ Dm0Gm46ZPEl+WbrqtaLmYkFCM7hYB4Rts5P5tlQ5osV5ge6xL0TYOrs1AUUVOcBV0Uu9 c7G8TwmhtEE3ZGHZtWwE3UXmYY/H0Jypwh5c45AfMNZVFNz/gvVIQPRMqpSe5NDv7rmA x8Aujq7snYVNU77w/ImuyyEO9zRRxVxhf9Mlm/ngIlBnd7rQPTmNzWHo0DvORcXhXGDW oa3/pKdTbCzSgzwIM7UGJLo2Qij/XbyxJZYmvOzgrGiM50EBzHIy0yMb3/vOOrOEH5R5 TLcA== 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=RKH4B95PNXl3C5rwhY+t4SQh2JqyVx0OlVSkqz5kPHs=; b=oeectHY3+FGVc/agi6NuwNyN398sF2xhBGlcpCDMWd9M8iKb+gzZGxWwx3eJzfSmyC pHnGb0FiHFDT8eDdj8TUu30s2tUNGceyPKSqQKbbJ+CAmiglMULjB3GSqHbbYSIZPE7t xi/NHUxKea72fXmH2nDOTd77bpOFESVg+8uWuCUPMeZUU9ejbt7QQ0bWf8FrgF6m8/y1 qqtPOYq+pbk9GBHeAVJTuyYJQXJ+QLYGdM3DwXXUWAxvRnWRCWG9X9voCvSXtSMyRB3H 7BMQusrXIFfvg0/ObgUXUq6AejJ1aW9+MXKYtix9tyLtQ+BeqK9Xj9mPn8Vq8Vv8ZX2H yl8Q== X-Gm-Message-State: AOAM531aofI+FxFNTOEKd01YEdpLpkwyddGkd5fhvNus4v0AW4D6Re2R oAPHFurL4+np3XrOUNCXYh9dnfjom+PorA== X-Google-Smtp-Source: ABdhPJzIpVTax+5kAioAX4RqrgRCu+Xj7+WatOE8BSD5lfOa9jEpdAJbBThTKEv2VFEfxhud6CQZkg== X-Received: by 2002:a19:c194:: with SMTP id r142mr32487669lff.87.1594126705082; Tue, 07 Jul 2020 05:58:25 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 05:58:23 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 3/5] cpuidle: psci: Fix error path via converting to a platform driver Date: Tue, 7 Jul 2020 14:58:02 +0200 Message-Id: <20200707125804.13030-4-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_085827_998985_7CB0247D X-CRM114-Status: GOOD ( 31.23 ) 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:143 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 The current error paths for the cpuidle-psci driver, may leak memory or possibly leave CPU devices attached to their PM domains. These are quite harmless issues, but still deserves to be taken care of. Although, rather than fixing them by keeping track of allocations that needs to be freed, which tends to become a bit messy, let's convert into a platform driver. In this way, it gets easier to fix the memory leaks as we can rely on the devm_* functions. Moreover, converting to a platform driver also enables support for deferred probe, which subsequent changes takes benefit from. Signed-off-by: Ulf Hansson Reviewed-by: Lukasz Luba --- drivers/cpuidle/cpuidle-psci-domain.c | 10 +- drivers/cpuidle/cpuidle-psci.c | 141 +++++++++++++++----------- drivers/cpuidle/cpuidle-psci.h | 9 +- 3 files changed, 95 insertions(+), 65 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index f07786aad673..e48e578aaa7d 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -287,7 +287,7 @@ static int __init psci_idle_init_domains(void) } subsys_initcall(psci_idle_init_domains); -struct device __init *psci_dt_attach_cpu(int cpu) +struct device *psci_dt_attach_cpu(int cpu) { struct device *dev; @@ -301,3 +301,11 @@ struct device __init *psci_dt_attach_cpu(int cpu) return dev; } + +void psci_dt_detach_cpu(struct device *dev) +{ + if (IS_ERR_OR_NULL(dev)) + return; + + dev_pm_domain_detach(dev, false); +} diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 3806f911b61c..74463841805f 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -17,9 +17,11 @@ #include #include #include +#include #include #include #include +#include #include @@ -33,7 +35,7 @@ struct psci_cpuidle_data { static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static DEFINE_PER_CPU(u32, domain_state); -static bool psci_cpuidle_use_cpuhp __initdata; +static bool psci_cpuidle_use_cpuhp; void psci_set_domain_state(u32 state) { @@ -104,7 +106,7 @@ static int psci_idle_cpuhp_down(unsigned int cpu) return 0; } -static void __init psci_idle_init_cpuhp(void) +static void psci_idle_init_cpuhp(void) { int err; @@ -127,30 +129,13 @@ static int psci_enter_idle_state(struct cpuidle_device *dev, return psci_enter_state(idx, state[idx]); } -static struct cpuidle_driver psci_idle_driver __initdata = { - .name = "psci_idle", - .owner = THIS_MODULE, - /* - * PSCI idle states relies on architectural WFI to - * be represented as state index 0. - */ - .states[0] = { - .enter = psci_enter_idle_state, - .exit_latency = 1, - .target_residency = 1, - .power_usage = UINT_MAX, - .name = "WFI", - .desc = "ARM WFI", - } -}; - -static const struct of_device_id psci_idle_state_match[] __initconst = { +static const struct of_device_id psci_idle_state_match[] = { { .compatible = "arm,idle-state", .data = psci_enter_idle_state }, { }, }; -int __init psci_dt_parse_state_node(struct device_node *np, u32 *state) +int psci_dt_parse_state_node(struct device_node *np, u32 *state) { int err = of_property_read_u32(np, "arm,psci-suspend-param", state); @@ -167,9 +152,9 @@ int __init psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } -static int __init psci_dt_cpu_init_topology(struct cpuidle_driver *drv, - struct psci_cpuidle_data *data, - unsigned int state_count, int cpu) +static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv, + struct psci_cpuidle_data *data, + unsigned int state_count, int cpu) { /* Currently limit the hierarchical topology to be used in OSI mode. */ if (!psci_has_osi_support()) @@ -190,9 +175,9 @@ static int __init psci_dt_cpu_init_topology(struct cpuidle_driver *drv, return 0; } -static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, - struct device_node *cpu_node, - unsigned int state_count, int cpu) +static int psci_dt_cpu_init_idle(struct device *dev, struct cpuidle_driver *drv, + struct device_node *cpu_node, + unsigned int state_count, int cpu) { int i, ret = 0; u32 *psci_states; @@ -200,7 +185,8 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); state_count++; /* Add WFI state too */ - psci_states = kcalloc(state_count, sizeof(*psci_states), GFP_KERNEL); + psci_states = devm_kcalloc(dev, state_count, sizeof(*psci_states), + GFP_KERNEL); if (!psci_states) return -ENOMEM; @@ -213,32 +199,26 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, of_node_put(state_node); if (ret) - goto free_mem; + return ret; pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); } - if (i != state_count) { - ret = -ENODEV; - goto free_mem; - } + if (i != state_count) + return -ENODEV; /* Initialize optional data, used for the hierarchical topology. */ ret = psci_dt_cpu_init_topology(drv, data, state_count, cpu); if (ret < 0) - goto free_mem; + return ret; /* Idle states parsed correctly, store them in the per-cpu struct. */ data->psci_states = psci_states; return 0; - -free_mem: - kfree(psci_states); - return ret; } -static __init int psci_cpu_init_idle(struct cpuidle_driver *drv, - unsigned int cpu, unsigned int state_count) +static int psci_cpu_init_idle(struct device *dev, struct cpuidle_driver *drv, + unsigned int cpu, unsigned int state_count) { struct device_node *cpu_node; int ret; @@ -254,14 +234,22 @@ static __init int psci_cpu_init_idle(struct cpuidle_driver *drv, if (!cpu_node) return -ENODEV; - ret = psci_dt_cpu_init_idle(drv, cpu_node, state_count, cpu); + ret = psci_dt_cpu_init_idle(dev, drv, cpu_node, state_count, cpu); of_node_put(cpu_node); return ret; } -static int __init psci_idle_init_cpu(int cpu) +static void psci_cpu_deinit_idle(int cpu) +{ + struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); + + psci_dt_detach_cpu(data->dev); + psci_cpuidle_use_cpuhp = false; +} + +static int psci_idle_init_cpu(struct device *dev, int cpu) { struct cpuidle_driver *drv; struct device_node *cpu_node; @@ -284,17 +272,26 @@ static int __init psci_idle_init_cpu(int cpu) if (ret) return ret; - drv = kmemdup(&psci_idle_driver, sizeof(*drv), GFP_KERNEL); + drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM; + drv->name = "psci_idle"; + drv->owner = THIS_MODULE; drv->cpumask = (struct cpumask *)cpumask_of(cpu); /* - * Initialize idle states data, starting at index 1, since - * by default idle state 0 is the quiescent state reached - * by the cpu by executing the wfi instruction. - * + * PSCI idle states relies on architectural WFI to be represented as + * state index 0. + */ + drv->states[0].enter = psci_enter_idle_state; + drv->states[0].exit_latency = 1; + drv->states[0].target_residency = 1; + drv->states[0].power_usage = UINT_MAX; + strcpy(drv->states[0].name, "WFI"); + strcpy(drv->states[0].desc, "ARM WFI"); + + /* * If no DT idle states are detected (ret == 0) let the driver * initialization fail accordingly since there is no reason to * initialize the idle driver if only wfi is supported, the @@ -302,48 +299,45 @@ static int __init psci_idle_init_cpu(int cpu) * on idle entry. */ ret = dt_init_idle_driver(drv, psci_idle_state_match, 1); - if (ret <= 0) { - ret = ret ? : -ENODEV; - goto out_kfree_drv; - } + if (ret <= 0) + return ret ? : -ENODEV; /* * Initialize PSCI idle states. */ - ret = psci_cpu_init_idle(drv, cpu, ret); + ret = psci_cpu_init_idle(dev, drv, cpu, ret); if (ret) { pr_err("CPU %d failed to PSCI idle\n", cpu); - goto out_kfree_drv; + return ret; } ret = cpuidle_register(drv, NULL); if (ret) - goto out_kfree_drv; + goto deinit; cpuidle_cooling_register(drv); return 0; - -out_kfree_drv: - kfree(drv); +deinit: + psci_cpu_deinit_idle(cpu); return ret; } /* - * psci_idle_init - Initializes PSCI cpuidle driver + * psci_idle_probe - Initializes PSCI cpuidle driver * * Initializes PSCI cpuidle driver for all CPUs, if any CPU fails * to register cpuidle driver then rollback to cancel all CPUs * registration. */ -static int __init psci_idle_init(void) +static int psci_cpuidle_probe(struct platform_device *pdev) { int cpu, ret; struct cpuidle_driver *drv; struct cpuidle_device *dev; for_each_possible_cpu(cpu) { - ret = psci_idle_init_cpu(cpu); + ret = psci_idle_init_cpu(&pdev->dev, cpu); if (ret) goto out_fail; } @@ -356,9 +350,34 @@ static int __init psci_idle_init(void) dev = per_cpu(cpuidle_devices, cpu); drv = cpuidle_get_cpu_driver(dev); cpuidle_unregister(drv); - kfree(drv); + psci_cpu_deinit_idle(cpu); } return ret; } + +static struct platform_driver psci_cpuidle_driver = { + .probe = psci_cpuidle_probe, + .driver = { + .name = "psci-cpuidle", + }, +}; + +static int __init psci_idle_init(void) +{ + struct platform_device *pdev; + int ret; + + ret = platform_driver_register(&psci_cpuidle_driver); + if (ret) + return ret; + + pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0); + if (IS_ERR(pdev)) { + platform_driver_unregister(&psci_cpuidle_driver); + return PTR_ERR(pdev); + } + + return 0; +} device_initcall(psci_idle_init); diff --git a/drivers/cpuidle/cpuidle-psci.h b/drivers/cpuidle/cpuidle-psci.h index ac8170684d4f..d8e925e84c27 100644 --- a/drivers/cpuidle/cpuidle-psci.h +++ b/drivers/cpuidle/cpuidle-psci.h @@ -3,15 +3,18 @@ #ifndef __CPUIDLE_PSCI_H #define __CPUIDLE_PSCI_H +struct device; struct device_node; void psci_set_domain_state(u32 state); -int __init psci_dt_parse_state_node(struct device_node *np, u32 *state); +int psci_dt_parse_state_node(struct device_node *np, u32 *state); #ifdef CONFIG_ARM_PSCI_CPUIDLE_DOMAIN -struct device __init *psci_dt_attach_cpu(int cpu); +struct device *psci_dt_attach_cpu(int cpu); +void psci_dt_detach_cpu(struct device *dev); #else -static inline struct device __init *psci_dt_attach_cpu(int cpu) { return NULL; } +static inline struct device *psci_dt_attach_cpu(int cpu) { return NULL; } +static inline void psci_dt_detach_cpu(struct device *dev) { } #endif #endif /* __CPUIDLE_PSCI_H */ From patchwork Tue Jul 7 12:58:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11648543 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 ECF7B912 for ; Tue, 7 Jul 2020 13:00:08 +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 C677220708 for ; Tue, 7 Jul 2020 13:00:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="N7AiAggI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="A88VM81I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C677220708 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=lhApMBBT3haGenLiNRDr6wbd91wvHwSNHxEt60NN0cM=; b=N7AiAggI8Ay5t3m+1ju77CZxy MKzescfXVowzolCff0R2hOFzBGkRw4a3O3neVLpOar67HD99PXyi4XJ7ylHnBSWW8Kzno0hEC52mU vtcwIy6dDf7If54sSZqfKgNwvk9EoXwUdIE87zB0GeuMHE5T8Q9zenY1mMfwj9HJ+DLyHCi5o0fx6 KlDSsg4YnTdp4zS04fnMLqIs1UXpeP19pMAbyQR/dtQC+xaqX/bXZct1KbXYx5GarBhHvsTbHlvMH asjmoOYt1/zsGi/dGhnqIWGl1OJ5HM5P5ANTmXyjvLh3RIRtyvC3k9AuvIWdcnkPHlEPV9MGssp/v LwmqBZeUg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnBQ-0006gt-JA; Tue, 07 Jul 2020 12:58:48 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnB7-0006Xo-49 for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2020 12:58:32 +0000 Received: by mail-lj1-x243.google.com with SMTP id t25so45166044lji.12 for ; Tue, 07 Jul 2020 05:58:28 -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=EkXZj4/pMT9pPcwacUaB98YwreiOuCxYZG9xrLmembw=; b=A88VM81IK+t1ZB6Q06hKJOLn4l/0OxUy5gRIgQgiNvaI4lyYmybOHoi/Kq63L95xjX gvrkw8iwNxowjbR//1jD2C9h/2B+2Y7lMHhfflH1wkEMCNxGZ4zpTDUMSuNHMJfydVGL H+QNZxR3i8p13BIcbZS2lymhDrCnxZEThXWkx8xn0eZsbHjtBOQ5XlisMuOq+IcPN1x9 Ex5iWq77Zn4FWWNlbIThuGbV76s0DBIw1XeLaWo0DHMA4AWPHKFim5m7DuY2k9syFmEq o4IwrkUrIPDk7gR9hjW3FFC2DOwDjCRSzJWl8DkMPvg/1NUqpxhF9Zru8ZCwIC53Dghd wbbQ== 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=EkXZj4/pMT9pPcwacUaB98YwreiOuCxYZG9xrLmembw=; b=PUnLB6VIJBUdsiEYp1vZ7a/bJPcO1XFwRza2mEn+jTlt3uAAyqSp3rQTdyjXeXfAzd /HF+Nnp8nh84/F483bxJv12nRJDLPfg0/OxOOXBOQTxAcFR1MIy+BDUQ57Qs9rHjaQ07 CG/+/HXSJws/b9EsNjtRNzUY8oX7Z4xfD7kKV2xf9Ejrmi6CdKNSQe/XnBprOzP7Zbjv N4xVfNyi1yRu55QFsmZ45UjdcmFLelVbpLbsLqpyISmOjadmo+dpiKxozMUisxM5CWIm 1YJoZDRtaQNYrvimJV+f2fnoPvfeps6TwwuY8FhxbZaAknXTL2PUxvuEF7HeP0jlYQuv lhjA== X-Gm-Message-State: AOAM532bTohjH+wQo1a+Oq9cYXxcv/uL2xIlNFnJdQW8y5MF8C88tCrE vt84LnwUMt8qmFis3J0G0jrH0g== X-Google-Smtp-Source: ABdhPJyBSriC7tiBtcgSZ/HW3ozSjjB3SMNR1qyrVjRG5PFGhtQNnT1gJ+8CVfwWMf7aVvGYjk6GIw== X-Received: by 2002:a2e:9883:: with SMTP id b3mr23503453ljj.390.1594126707435; Tue, 07 Jul 2020 05:58:27 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 05:58:26 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 4/5] cpuidle: psci: Convert PM domain to platform driver Date: Tue, 7 Jul 2020 14:58:03 +0200 Message-Id: <20200707125804.13030-5-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_085829_278894_E021B11C X-CRM114-Status: GOOD ( 17.93 ) 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:243 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 To enable support for deferred probing and to allow implementation of the ->sync_state() callback from subsequent changes, let's convert into a platform driver. Reviewed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 45 +++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index e48e578aaa7d..bf527d2bb4b6 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -42,8 +43,8 @@ static int psci_pd_power_off(struct generic_pm_domain *pd) return 0; } -static int __init psci_pd_parse_state_nodes(struct genpd_power_state *states, - int state_count) +static int psci_pd_parse_state_nodes(struct genpd_power_state *states, + int state_count) { int i, ret; u32 psci_state, *psci_state_buf; @@ -72,7 +73,7 @@ static int __init psci_pd_parse_state_nodes(struct genpd_power_state *states, return ret; } -static int __init psci_pd_parse_states(struct device_node *np, +static int psci_pd_parse_states(struct device_node *np, struct genpd_power_state **states, int *state_count) { int ret; @@ -100,7 +101,7 @@ static void psci_pd_free_states(struct genpd_power_state *states, kfree(states); } -static int __init psci_pd_init(struct device_node *np) +static int psci_pd_init(struct device_node *np) { struct generic_pm_domain *pd; struct psci_pd_provider *pd_provider; @@ -167,7 +168,7 @@ static int __init psci_pd_init(struct device_node *np) return ret; } -static void __init psci_pd_remove(void) +static void psci_pd_remove(void) { struct psci_pd_provider *pd_provider, *it; struct generic_pm_domain *genpd; @@ -185,7 +186,7 @@ static void __init psci_pd_remove(void) } } -static int __init psci_pd_init_topology(struct device_node *np, bool add) +static int psci_pd_init_topology(struct device_node *np, bool add) { struct device_node *node; struct of_phandle_args child, parent; @@ -211,24 +212,24 @@ static int __init psci_pd_init_topology(struct device_node *np, bool add) return 0; } -static int __init psci_pd_add_topology(struct device_node *np) +static int psci_pd_add_topology(struct device_node *np) { return psci_pd_init_topology(np, true); } -static void __init psci_pd_remove_topology(struct device_node *np) +static void psci_pd_remove_topology(struct device_node *np) { psci_pd_init_topology(np, false); } -static const struct of_device_id psci_of_match[] __initconst = { +static const struct of_device_id psci_of_match[] = { { .compatible = "arm,psci-1.0" }, {} }; -static int __init psci_idle_init_domains(void) +static int psci_cpuidle_domain_probe(struct platform_device *pdev) { - struct device_node *np = of_find_matching_node(NULL, psci_of_match); + struct device_node *np = pdev->dev.of_node; struct device_node *node; int ret = 0, pd_count = 0; @@ -237,7 +238,7 @@ static int __init psci_idle_init_domains(void) /* Currently limit the hierarchical topology to be used in OSI mode. */ if (!psci_has_osi_support()) - goto out; + return 0; /* * Parse child nodes for the "#power-domain-cells" property and @@ -256,7 +257,7 @@ static int __init psci_idle_init_domains(void) /* Bail out if not using the hierarchical CPU topology. */ if (!pd_count) - goto out; + return 0; /* Link genpd masters/subdomains to model the CPU topology. */ ret = psci_pd_add_topology(np); @@ -271,9 +272,8 @@ static int __init psci_idle_init_domains(void) goto remove_pd; } - of_node_put(np); pr_info("Initialized CPU PM domain topology\n"); - return pd_count; + return 0; put_node: of_node_put(node); @@ -281,10 +281,21 @@ static int __init psci_idle_init_domains(void) if (pd_count) psci_pd_remove(); pr_err("failed to create CPU PM domains ret=%d\n", ret); -out: - of_node_put(np); return ret; } + +static struct platform_driver psci_cpuidle_domain_driver = { + .probe = psci_cpuidle_domain_probe, + .driver = { + .name = "psci-cpuidle-domain", + .of_match_table = psci_of_match, + }, +}; + +static int __init psci_idle_init_domains(void) +{ + return platform_driver_register(&psci_cpuidle_domain_driver); +} subsys_initcall(psci_idle_init_domains); struct device *psci_dt_attach_cpu(int cpu) 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, }, };