From patchwork Tue Oct 29 16:44:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 178039 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp51951ill; Tue, 29 Oct 2019 09:44:57 -0700 (PDT) X-Received: by 2002:a19:c192:: with SMTP id r140mr3158410lff.48.1572367497349; Tue, 29 Oct 2019 09:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572367497; cv=none; d=google.com; s=arc-20160816; b=bdvgkwx2ZHh7z5pNH7uM408xpgeaVkxdMttDU46Ts8Vli6f/WtXB5XQFQMqt6Yn0Nl RBrjJwNCOPMjdg5PVHoCEpNwrNdVRg9I1D5o+eLI2GsBV4Vh4zw3vxJ+vm3ysSKncjb9 nfTyPsk0K8ldlM5inHvD36uwvJiyT8sNsSvZkZ4vHFmIFD/bXAHZ8/e33Iz5Z2PxHWJN vDrlvBrwcZUw3aD4nDv6BrP0Swsarys4bMPkpK+OTYdVCsKQbIj/UW0sOByscmwum9Qg 1Tj/jVpuKnzadAZHYnoVmbPXFiEyet/KKEI8IVV7pRPrJKp4aQAPCZiJ8W3uD6rGaq3k VbwQ== 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=gp0cxGjsLa/5p2k8fB9GEAU+2hCtpg307yRdN/E/Ges=; b=Uz8xK7sJ3h/XG7XEbG7OypiM3Hocmmh/znxtu2owV9jYMtL/FLDPRMeBSrFHN2hr2f Xq/rt094+zZBLtQt5mtMZmuLi1KYe/eMDX7imLvVpr00S3iG4UUJfHLQNCZX5ufAfa5/ aoKQESHhbLh/BnKKEpPRK3ErpWhb2XoRHmtAU30g3VC49rsg4HaZozfteDdnaBh5to7o pMZJEYKct1/NorhwwOygjTTJe0ozM5R2Huu3iD2TSlJrloHtZHnaz7hw6SR1wO8fXRHS ITu8EmuZLIRJ+y0Tx1+3Z5+AG3lWtaTghsoisz24sqhtjWZW1LVuuvkRdMrWCQpfvoGj J0iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kloNjm7Q; 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 h2sor5741344lja.42.2019.10.29.09.44.57 for (Google Transport Security); Tue, 29 Oct 2019 09:44:57 -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=kloNjm7Q; 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=gp0cxGjsLa/5p2k8fB9GEAU+2hCtpg307yRdN/E/Ges=; b=kloNjm7Qehm+0bNq+PjeVTCYJebZI/Nt6BoOXCGhZ42Lubnovk82si9lvQTNSrPnjm yzvWB1RpsrPT+K1kmcm6o5d4IqmC41y1IyMDP13qMcKxRrQh2YmwJqIaW3OBGnAjTFuV DszyrwgR8jjtwkB3ejpvj2tTiJ2M8eEhgOD179EDaWIRqU83CoUZIlGbm7U8eQ9vDiTA zsrKHMsBtxGZAqsMxXGD65M6PTDqW6izTs0p+m4Hb4Xe/idX0r3dkQ8L+nBIBxMca/SL cEDO7mPDzkN1WnosM9QLAZr6n83sytpWKb58MPsofUsZCNBPGuC7ElmYfAbQppnCVQM3 bhoA== 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=gp0cxGjsLa/5p2k8fB9GEAU+2hCtpg307yRdN/E/Ges=; b=AOGyRmCb7IbwNYxuBKT9NZ/Uiz2XD/tU2yJS7TSQyUwC7Iy0d8oybt3DX9rVN0hkPB Mx+eX4xMYE7VjeujuEpilfUEaP+FFPl8FxoXvCW/KISWGDd8Ai4qBFjyPTr3UVxs8yjW rMpo0IRvZ6RP+h98zpmatR/I00r+gQHyCq6DG382x2qGkbShmavB3AQrumAOfn7jUFml 2aWHNpHazIN1iNXx1UQ6FSQsrOOsCg20xMy1/mhab5wtUNSimfZk1QDIbQyR1mmN5tTa RIjxdeu2+2x0O1UEhDH5HVVpyTaK/TetUtUXkQaByA4P9ya4Hy+tSuwuQvYqX4gDMFtw UGyw== X-Gm-Message-State: APjAAAVEzvAzoqCcu9S7NR6dhlYIUnELJI8FvhJw+Su+NPWGgztQ16sI EA+JyjeSOe3jYRnIdju5NfYZiFhj X-Google-Smtp-Source: APXvYqxF9BFsEOTuLQ4K8J/4i3dG6qTKDv5+wlVsmO+sGvo23A7onGcqdB8AKr150o5WRbwcKMmJAg== X-Received: by 2002:a2e:9782:: with SMTP id y2mr3394331lji.46.1572367496902; Tue, 29 Oct 2019 09:44:56 -0700 (PDT) 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 f28sm2048161lfh.35.2019.10.29.09.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 09:44:56 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Daniel Lezcano , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Lina Iyer , linux-pm@vger.kernel.org Cc: Rob Herring , 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 v2 08/13] cpuidle: psci: Add a helper to attach a CPU to its PM domain Date: Tue, 29 Oct 2019 17:44:33 +0100 Message-Id: <20191029164438.17012-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029164438.17012-1-ulf.hansson@linaro.org> References: <20191029164438.17012-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 v2: - Reorder patch to be the first one that starts adding the PM domain support. - Rebased. --- drivers/cpuidle/Makefile | 4 ++- drivers/cpuidle/cpuidle-psci-domain.c | 36 +++++++++++++++++++++++++++ drivers/cpuidle/cpuidle-psci.h | 12 +++++++++ 3 files changed, 51 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..bc7df4dc0686 --- /dev/null +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -0,0 +1,36 @@ +// 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 + +#include "cpuidle-psci.h" + +struct device *psci_dt_attach_cpu(int cpu) +{ + struct device *dev; + + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (!psci_has_osi_support()) + return NULL; + + 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 */