Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5555229yba; Mon, 13 May 2019 12:56:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3w7+UbNl1N2Y9ccX6/+zoJmqHY1r38YKuTRh0e2eRTpEjrxV+JvdmkoMXuj/Fo1ryaqEa X-Received: by 2002:a17:902:4623:: with SMTP id o32mr16137849pld.276.1557777407423; Mon, 13 May 2019 12:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557777407; cv=none; d=google.com; s=arc-20160816; b=T2A7MH96OfguhOxRYeLc+sd9dCekjcdjb4gCRv8eg5xhKI68+Vlsao2xu6UJt9uJzC PrOneRppxAhvFehg5zjbGMkeFQ4Hn6j1kE2E1wZN93gfDiiwsiDQWVsllqKyjcGxn9tE jI4zkvy7FWaf9tHKZMM40f7/pR9vS99IQhFZos9NhFRbptJdnn87z2z9wS2YU8+AfFtA Mb9OxAQrnIUdr0ZwuJ91vFaxLXFDLxl4UES6JDKtAaZyDq1VDMWpsJV1CSlQoAiIhOWu 6qmbO8NrcrCvObgTgYOJFGcJ2CIguMRnaC9yWUPFW3bBsE4THt64gKG5pCbXZjaDWiyg hKtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=dGxlUq0F/FDpnPaKeNSyOtOJ53S5dvH/a5Ne38qnqFb7KbTioJAQt1hMTR7SqiFzAZ 0yUN6GG08ZuzA9mWTlynQruWg8+VMtLTkDBx0X4vqR/3+++DZ2xfm41ciCm8K1oWk+70 SXur5eJE03QpvdH8EAm6K8/8XEP4aeCyHU3FE0Xo3ScmxfFwhgJLFHRqf3OhGj5nBd8T tUZlf2vg1ZgttP2i5XlVBZZf1mXHJBzbG9hlmvk8vedxaFGMgqBdXeoBvoJcOXneONlB YlgVXNAuSTLn2tPEDAtq9H6FI3eGg5hw/UHlh2I7zyjZULDbRxFP2RSvGFtfZ8ayzrBH nPEw== 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: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b40si18677921pla.277.2019.05.13.12.56.31; Mon, 13 May 2019 12:56:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YrDb+TI/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbfEMT3m (ORCPT + 99 others); Mon, 13 May 2019 15:29:42 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34160 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbfEMT3l (ORCPT ); Mon, 13 May 2019 15:29:41 -0400 Received: by mail-lj1-f196.google.com with SMTP id j24so11286745ljg.1 for ; Mon, 13 May 2019 12:29:40 -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; 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=e/yHWV97zD5dCXBO4+XMaZ9zXZaGAbjHV7EzB7GqB2o+dF8HW8sN5W642fZ68Vwe30 mcs4m4utEMd001MiKlaR3pRWVgyPkwTct0BFQXB7gOA9yptTHjsd/ZU6iMBEGnZwqiUP EavCYeKot3/eKKc03DjVrvCUbY0NLdbNWIgWcF7lzaSM8sgF8Zf2/8/Naux/wfjcWHjs y44CmHxfMck4MciA1+JCRqJ1oNGHA5OgPz5ie7Han/y9d6h4Kfgm0XWhh8Nd+/MvkglZ 70mAcekQ960J3SKBdlL01CO+/eFELtDChYDMcCaoKqGyCbYLgnRW2f7Zn1bp+Sv2iXQU PjeA== X-Gm-Message-State: APjAAAUEJiYZ6E2DJ0BBQ9sm7iwIlBS4fFDqQfwSjhFEq/XbZwi93gLP j98116K0h14cZMmsfazh4I+NZA== X-Received: by 2002:a2e:206:: with SMTP id 6mr13170535ljc.59.1557775408048; Mon, 13 May 2019 12:23:28 -0700 (PDT) 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(+) 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 -- 2.17.1