From patchwork Mon Dec 30 14:43:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 182622 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422315ild; Mon, 30 Dec 2019 06:44:22 -0800 (PST) X-Received: by 2002:a2e:a0d5:: with SMTP id f21mr39441325ljm.106.1577717062571; Mon, 30 Dec 2019 06:44:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717062; cv=none; d=google.com; s=arc-20160816; b=BOoFigacAC6gFOytJh9zgJeTzQ4BQjqusofx4TelqtX1Yh5WxIKhp2JRSUzHebwDDU AH5kuPOAKryfN9/jKCuqesR8FUXpIUx+aMwMoPYf8UC2epEbxhJpvLO4D8ERUmziU0IC F0RR+HN+TVAsrO8BCeJ+gxt+qIwJ3bX38MOcAO7G84WmDZoYfoHOfNMzBxBCbLG6FiJo RlKui8an+DAl5GcM3vWNGgLPzrOACrPK57ESiTvV++CB429T3+RSk9raseuMiMyr8ZQJ QT6wtYTBlBXx3pFqU/MmmrgTAO21DeHoCanNhGA35PdLNXk+30zHV62rqjvaQVwyrwIv PtxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=neea4kQTvG+Bpgec4NpbRFMjAla+zHuzZZgjs6GRGkc=; b=oIiuoC9LWX0ZX3FAR1HwTkyNh/XAyvzm4/H7yeym10vsdhi5h6+vRxDlzZ1LzbmpsC TJuzCfn7EZM/WM9BnLCQZQmHMlEfgkXkXp1TEaecc8st9nKKnp+QkEQf5SLwdZX3BWua Vb/Yqiqy9gP9DFCAfjUW3TQn7U2Gni7CMLIByLp7Bw6L8iaLJnMG7J5mJQWaRJ/9TlgZ D5W5yFgOzjWg8zsiBaHy281B7Kap5W2gW8CHAZtPFjjngawfjwokr/D4lolTZTjmvix5 DnqznrNXTRV0S4Ev6Fs5694P3PayhTJ969xM2DzQtcvsyelXAYDiV/E6PLmm4L+GjxXS qFvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CY8w9n0q; 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 f1sor19641306ljf.31.2019.12.30.06.44.22 for (Google Transport Security); Mon, 30 Dec 2019 06:44:22 -0800 (PST) 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=CY8w9n0q; 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; bh=neea4kQTvG+Bpgec4NpbRFMjAla+zHuzZZgjs6GRGkc=; b=CY8w9n0qANi3pwpse5njlfUuAXhBW7I2P8v6T8Momocn6zaJyS9eUNpXR6rklTo6dg sq+oD3qSYMqB0wdHlDpE3jkyYaDDnJHCkfrXPBz1GfhmtlV7apr9LScWjde4LbAIiZx0 RLOWOqpMSJiQcd3lmVt5H67wYDzWg+AdVC9P1T20yfcXI8ABlEREGNiOd4yO4jG7QCUI bkADMMLprTLR0eR+X7OmdFXwjGSeYM0Ngk65Ev77A+7MtvMrv27NP0obM/n5DvFCWGYy 5z7X2a5X9oYhJZ3SAkZHCYhKtbgKBoaNCtXSM71AdSInmuszfBFuZrl7vxgoyZ5wjZ4m 6I+g== 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; bh=neea4kQTvG+Bpgec4NpbRFMjAla+zHuzZZgjs6GRGkc=; b=pIA5/93KwQGQ7d0UJU8M4qAV4o74koHI7tMari7+SZJcxs79gQikZ5V1DzJDV3wPDe f68TstvCSx+KgMOQYnFPcoa4vCK++0exIRp/U8dqekGoQcw+6aC2C4pszX4XHjfqfaAY /iapCf8gQN/ieoyvybRqyQlPNFpOBw7JhKle1w3Qt09IeZXR6auxsyIJp5Y4sWBX81Wv e1uwcPjzbnn2ueJmU1OWnugJH6ZCyAnovLB3mXgSsIyFepGuijkBEdlt5xds9Fp5HBZo UVAqtHmtEvtKWxRV0Eij5lWJS0ltqH5/VK4hMcRmtQhOGOd3E5E+D4jFHz64Y4vQ5gjX txJg== X-Gm-Message-State: APjAAAUOj6SrfO+J2PV1VT6c9BLE7WlNFqJBRN6O3fPydmrDk6585cRh Eiw5c897BejzY0W6jBdAwfKyi13I X-Google-Smtp-Source: APXvYqz4pHdrSZYvR9LPkn6aBxofeWRY+5WpuR/T2iFRqr3dH9alwMysRzcX9iPHqQj6c18Apu+KPg== X-Received: by 2002:a2e:93d5:: with SMTP id p21mr40357019ljh.50.1577717061929; Mon, 30 Dec 2019 06:44:21 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id a21sm18744931lfg.44.2019.12.30.06.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:21 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 08/15] cpuidle: psci: Add a helper to attach a CPU to its PM domain Date: Mon, 30 Dec 2019 15:43:55 +0100 Message-Id: <20191230144402.30195-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> Introduce a PSCI DT helper function, psci_dt_attach_cpu(), which takes a CPU number as an in-parameter and tries to attach the CPU's struct device to its corresponding PM domain. Let's makes use of dev_pm_domain_attach_by_name(), as it allows us to specify "psci" as the "name" of the PM domain to attach to. Additionally, let's also prepare the attached device to be power managed via runtime PM. Note that, the implementation of the new helper function is in a new separate c-file, which may seems a bit too much at this point. However, subsequent changes that implements the remaining part of the PM domain support for cpuidle-psci, helps to justify this split. Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v5: - Declare psci_dt_attach_cpu() as __init. --- drivers/cpuidle/Makefile | 4 +++- drivers/cpuidle/cpuidle-psci-domain.c | 31 +++++++++++++++++++++++++++ drivers/cpuidle/cpuidle-psci.h | 12 +++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 drivers/cpuidle/cpuidle-psci-domain.c create mode 100644 drivers/cpuidle/cpuidle-psci.h -- 2.17.1 diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index ee70d5cc5b99..cc8c769d7fa9 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile @@ -21,7 +21,9 @@ 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 +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 ############################################################################### # MIPS drivers diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c new file mode 100644 index 000000000000..87f881c21af1 --- /dev/null +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PM domains for CPUs via genpd - managed by cpuidle-psci. + * + * Copyright (C) 2019 Linaro Ltd. + * Author: Ulf Hansson + * + */ + +#include +#include +#include +#include +#include + +#include "cpuidle-psci.h" + +struct device __init *psci_dt_attach_cpu(int cpu) +{ + struct device *dev; + + dev = dev_pm_domain_attach_by_name(get_cpu_device(cpu), "psci"); + if (IS_ERR_OR_NULL(dev)) + return dev; + + pm_runtime_irq_safe(dev); + if (cpu_online(cpu)) + pm_runtime_get_sync(dev); + + return dev; +} diff --git a/drivers/cpuidle/cpuidle-psci.h b/drivers/cpuidle/cpuidle-psci.h new file mode 100644 index 000000000000..8609482cf490 --- /dev/null +++ b/drivers/cpuidle/cpuidle-psci.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __CPUIDLE_PSCI_H +#define __CPUIDLE_PSCI_H + +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF +struct device __init *psci_dt_attach_cpu(int cpu); +#else +static inline struct device __init *psci_dt_attach_cpu(int cpu) { return NULL; } +#endif + +#endif /* __CPUIDLE_PSCI_H */