From patchwork Wed Dec 11 15:43:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 181271 Delivered-To: patches@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp701814ile; Wed, 11 Dec 2019 07:44:05 -0800 (PST) X-Received: by 2002:a19:22cc:: with SMTP id i195mr2720213lfi.148.1576079045287; Wed, 11 Dec 2019 07:44:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576079045; cv=none; d=google.com; s=arc-20160816; b=roIUSbHuZCXdalQzgCPNcS8pbyTx0Z41K59jUatedMpZvX9C8xffXtfL8zE6YmiUv/ MjxHVNQqunv8F2P0vA7SOJlSb9zrVjC46JEFyxcpNC2qDm4Kai1NlqKMFIY2gvoS5VId dxX6cOOSiXegMelEZmR2z4F/NXR5FIDlO7R+cb7KLX9ech4qeu6U6ANfcY6oBNCW/+NR 8R/0RL25YSZ1v6PCLd/yVgsxnEtEs94wUeeKFYxefXCxZyYZvbEKyIqVUPX/1m0HQT3g j4lamf/bZSzGUWkB36CEx5t3HOjcCx6bYaHEa/x1Iyq1HO25STTs7MK5Mjbs0AcVQVyY os7A== 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=XRfmkf4JnKo9PHq3PVzPd6h/hHi59OtQm8uNLFVlFhw=; b=nejCKWcHMcagCZE8EkiF6Rwr0jhn7zJlOPRkGvxPEPxwC2Qs2MxXyPvMHpkbID+1eh rUhfXIi8ZYMXzPn/9CTOysoJ+1rw5vY218AOAwRcWcwXpzfIzawYTXres1ta7+R529ZV AVI/XyGSQXb5RToLIaTIUfEiCfw863wzBr0ysgRKFNn+KEeyN3ppdAyBE+k+G/uCAAx1 9npjiew+/9vilt8M41zn/ZSbRHW3m3DlpQS4VGdd3lwKemN+bx+6cU933yANS+V13wAf b31t55AOBQneJLQ2olbnIxZ/uATDCAjCVpRejdscWH+jBWYZCP/GuWf1uMxCcfeVwXZ+ mfNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vlqC0QWg; 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 c4sor863650lff.49.2019.12.11.07.44.05 for (Google Transport Security); Wed, 11 Dec 2019 07:44:05 -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=vlqC0QWg; 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=XRfmkf4JnKo9PHq3PVzPd6h/hHi59OtQm8uNLFVlFhw=; b=vlqC0QWgeO1GZemTWBSNt6UdSV9A9IQdBl8vegBUr1H/Ag8x1Cd9tjpyIHNvG5fyB9 QTBTZKMXiUxLQviC7xKcLGZ2YubJVmmZtnTA5ZsQ7z66HDc5/7k1BH83pqFWczznzZwS sx36NLkjtCKlPPRvRmiJ3IbuE4YWExffudRu5xmaJQC5nsLvmc9+zlEhYTUXYThE1QiP i/4ay48+KWFMXOSTi3JOMjXj8gMa3uArXqiM9CeNFERCQK/vNms394Z7BR1ZUpEdUIxg 95KsTrmnB2uRI8q9or5tnD7lPJeFGgCXP+jS+vKxOo0opD/4GtZL/ACyneRM5uIdV1Vl W/Jw== 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=XRfmkf4JnKo9PHq3PVzPd6h/hHi59OtQm8uNLFVlFhw=; b=HlNQKm+0dTqqfX3lzK33F9P3ol+99EHK7tkfyinnVQZsrQ91uBrazIm5mJrdduvlgK WcfIgtNwIq/Iif2+7XOTOADdXqCugSf7+wdsEqiROfhxMcLGQeawxyt9Wp+nJrPHudul sxwKRbBxT1jNQBD9b5Vs/FKp7pLJvOjKEK4h5zRYBjK4S/xjN6hdL7jJ36hSyIVdRo4o eW51nbKPywBQnDbdsj2+Wb+ppRnmM3UlzBObmkZBO1Hln+9eWEEUWw21ZrULTvNWMcII 7/TXULQ0ksV+T0fgfdEbwdjS2WQJmNpBVjGgbiKVEuDQys6VozbvAUo1iQm6VIRhpNyr xjQg== X-Gm-Message-State: APjAAAVK6qb7KQx+luBpCiKwP9McoMOmysb1EHwMLvZt5PNtWugaeq1a 45qCnGJXTfkWcMAyrzBD9uJ4cY4v X-Google-Smtp-Source: APXvYqyhMsqjbCZuwpuxXeIZk5TZCnSHx3W6LBzXGYi7B+TXl9c4TYuR1rKG/FBz0EPE2iPVxo0Zow== X-Received: by 2002:a19:f006:: with SMTP id p6mr2619628lfc.94.1576079044833; Wed, 11 Dec 2019 07:44:04 -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 b14sm1389608lff.68.2019.12.11.07.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 07:44:04 -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 v4 08/14] cpuidle: psci: Add a helper to attach a CPU to its PM domain Date: Wed, 11 Dec 2019 16:43:37 +0100 Message-Id: <20191211154343.29765-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211154343.29765-1-ulf.hansson@linaro.org> References: <20191211154343.29765-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 --- Changes in v4: - Drop check for OSI support in psci_dt_attach_cpu(). --- 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..656ef3d59149 --- /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 *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..0cadbb71dc55 --- /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 *psci_dt_attach_cpu(int cpu); +#else +static inline struct device *psci_dt_attach_cpu(int cpu) { return NULL; } +#endif + +#endif /* __CPUIDLE_PSCI_H */