From patchwork Mon May 13 19:22:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164061 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728500ili; Mon, 13 May 2019 12:23:28 -0700 (PDT) X-Received: by 2002:a19:6b0d:: with SMTP id d13mr14261970lfa.79.1557775408412; Mon, 13 May 2019 12:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775408; cv=none; d=google.com; s=arc-20160816; b=z6bCSPmX0iKsGJkAFYHqKec0t1jF6+Aw8tc8dv45k/85nsZI0mPZqsZ9YLPPBzmGaz fyvVcBlx0g5x24VYPv/BDSC9tbD51lo4iw3+LlHyZLgs+1PoOtylv9K4EKesN/bmrQYN KAc+b+BdAs2imIjE3NgSL0N3ijBzFE8tP4QUYTHxhTJqxKUOJD3IF/vGerVzH3QYPaH9 AGJTn5qpnzc3hMJwQtv36ay7r5nr30kXGsqGGTdFIVeQMGL9saibF3qE/aqDhWzJRb0O gPPgXZ30qCwLAlb4I7TIYrqR13TVoU/FpJlg6dM/ZFmnEfGr1tYhgSVtI9mwnlucSXuB 1nBw== 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=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=KQuZIjubfUifv3ssAR+G5wSzyOOUxlNCuasLn5gNJby4swFZF+k1skuF4poE1p2Ir2 v8H4y/Vk5dtjlV1UzsO0pb+EkFrfwKCSlbBCGT+OiKxXGhlHbED1HiTQItj4gsG1fMGO U87CrT/uqQqSVkcqLk9OAP5/odt7KoO4cSNJ3peQWbLx0eiIlXIImhgVzTG2/GHQyx1E 0dRVfN//cdr6+SfN+leZYYUpMqL0CR8cs8L61UzFhhnrXt2GxaRHenX/J1OZwtN9Sqvv PtKkW9y5wlUONz/0Pu1yXGgTqsvEUS3LnKaD6bXkHxZGhOcn9svUUCUohvfmeLm2wO9m OSag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YrDb+TI/"; 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 z12sor2954913ljb.2.2019.05.13.12.23.28 for (Google Transport Security); Mon, 13 May 2019 12:23:28 -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="YrDb+TI/"; 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=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=YrDb+TI/qptrO7/5RXe8SeC+HyCzsJJl8ml3Jr2kE2brTGKdFR7/IJ+N4lXVtKfgGo NAHroyR3jEv97wAFOv1N3DRBDosPKmtXcn1hEpIBtK5wsOrvMlCDRGJxZwA8Y/CGP+8R ab2aAEL3gSBOsIHFKZCpimEz0v0pvvsft17f2AvJ1ojeV6J8wLK4ixd+AfhWKPZ/c7ZC sQLCc6Vgosbnw6yG7ZCHQQ1u7R7deMgYPyyYMCopM3U1unF1AFl5Ap4t5OT1xuDe8t5f uoNBPb8pfj6ZvLWRNfIZPJf9225Y1ujm2szcS0/1CCTN+KdvBfR2+owHypKzCboaNJCY oIXg== 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=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=bxnlJKGLYvrW5p+0wqgRFvxLKQhKWrdmB5ZjY2ItMTtL8JqIz5fNT3ilK7ydZamlk9 7AaNT+n9WulopeT4tKQc30aHjwO4kTnKZDtELcfI05yAYHRtpjDHe+qDodX2qcXIGAnn /wmZ2eRF9NJgtcwPKzMXGqIs44BElK3o6WjnxXZhecpSroTRF/2vhMo0k3TvTuB4Qxqr mmPnnq7I3wl54Ml5GOXZMGGi47BQMFUXSMOq+UQsJY0gkK9Md61/O5Z7OWwo34HAkqWZ CQLRXELcfn/bqQ0OzVBdPt5aVmXkRp0bJVjjPHPx7Zbwau339BvufuJ70PPYXzf55Hyf I9PQ== X-Gm-Message-State: APjAAAUGCbIF717Moc6ul/rDfJBQyn6ljNS9RJ6zl3abvm9dmZ8A1wuy O78ksBHM+NvDkLsLiWdEqblr1gqc X-Google-Smtp-Source: APXvYqxhImmrN+c//ITxcw8U+57BeFavH+R85RVOLDvIyx6W8pcBzSGLx1AMwoyfzWMRSAkXmhUcdQ== X-Received: by 2002:a2e:206:: with SMTP id 6mr13170535ljc.59.1557775408048; Mon, 13 May 2019 12:23:28 -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 q21sm3449365lfa.84.2019.05.13.12.23.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:27 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 12/18] drivers: firmware: psci: Add a helper to attach a CPU to its PM domain Date: Mon, 13 May 2019 21:22:54 +0200 Message-Id: <20190513192300.653-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> Introduce a new 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 use dev_pm_domain_attach_by_name(), as to be able to specify "psci" as the required "power-domain-names". Additionally, let the helper prepare the CPU to be power managed via runtime PM. Signed-off-by: Ulf Hansson --- Changes: - Take into account whether the CPU is online/offline. - Convert from dev_pm_domain_attach() into using the more future proof dev_pm_domain_attach_by_name(). --- drivers/firmware/psci/psci.h | 3 +++ drivers/firmware/psci/psci_pm_domain.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index c36e0e6649e9..b4254405b8ef 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -4,6 +4,7 @@ #define __PSCI_H struct cpuidle_driver; +struct device; struct device_node; int psci_set_osi_mode(void); @@ -16,10 +17,12 @@ int psci_dt_parse_state_node(struct device_node *np, u32 *state); int psci_dt_init_pm_domains(struct device_node *np); int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, struct device_node *cpu_node, u32 *psci_states); +struct device *psci_dt_attach_cpu(int cpu); #else static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } static inline int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, struct device_node *cpu_node, u32 *psci_states) { return 0; } +static inline struct device *psci_dt_attach_cpu(int cpu) { return NULL; } #endif #endif diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c index 3aa645dba81b..1cbe745ee001 100644 --- a/drivers/firmware/psci/psci_pm_domain.c +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -383,4 +385,19 @@ int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, return 0; } + +struct device *psci_dt_attach_cpu(int cpu) +{ + struct device *dev, *cpu_dev = get_cpu_device(cpu); + + dev = dev_pm_domain_attach_by_name(cpu_dev, "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; +} #endif