Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10463053imu; Thu, 6 Dec 2018 01:18:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/VEGvji4PYlBDPpAq/4w05ujFkogVf5cg08wlT684WHKF2rh1oI99uovN51uhhN3E+5f6cG X-Received: by 2002:a17:902:2868:: with SMTP id e95mr27547314plb.317.1544087911337; Thu, 06 Dec 2018 01:18:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544087911; cv=none; d=google.com; s=arc-20160816; b=kNni5MqgOE6oa5C3pw59OV6yR5qmz0Rv+eiAXXpYXcP3sXgkPHpK9gO2rWpxDWLZCu 2ZVLwfkOCInOZi6QbHyHA1pQ61wpFr3YeI3vJpF9xGLEL7IzQk8KRfyTjgk3lZa6aMmQ tYWpTxuJEbK9uljEd/pFfuE8vlbEpCLVqnCddt/0oR2IQQmYfMgFCP2kWLNs9pKu9gku PcwpmHp5JBceiOAYwtzuSvPltDfG94INcjmeuQ9Az5SFoaf5dt99stjpTLkEEJs8a863 kgEpm4kYmOflMsOO8rw6R3QHD07D42TdJkNz74ExywktGMDh6bdvb41YOZwuyUu5CvKm CsDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oplyraUjlzT1MdYD0jbSQna4BlEOoZ+ROrl7JO6ZcX4=; b=eNuLMJw6hMUasgKOSmY4C3gBuKKtePYHiSp38KxjvsT3GvhkHt61b2o67oijmXOgw0 wdZhX5e/hLPuQopVdPD80LtSG03RtWsv1UGjPTtUpfdbj7u/t8Jpbq6GLc9DOi1iLaPU XIwkmYiGVDTCRP1O74BgZAvULFT/bTxx+0uezROIAc9g0SQUCcBCNz7XNLLBwsqH/+XN DyQNKCospO70Rvip7BoBukbrl5xY4QQQqlgzqr09RFq6fkAnXyw2Sp6h6rgVa8Yg558S 0Us43OTHuSLqB+o5WjXWuS99j2+xogwFkyn7lC3E/34AR5wZ4qFm/35gxHacmIw2GFv6 e/mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QCX96gWO; 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 o8si20242738plk.28.2018.12.06.01.18.15; Thu, 06 Dec 2018 01:18:31 -0800 (PST) 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=QCX96gWO; 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 S1728930AbeLFJQB (ORCPT + 99 others); Thu, 6 Dec 2018 04:16:01 -0500 Received: from mail-vs1-f65.google.com ([209.85.217.65]:33037 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727783AbeLFJQA (ORCPT ); Thu, 6 Dec 2018 04:16:00 -0500 Received: by mail-vs1-f65.google.com with SMTP id p74so13875739vsc.0 for ; Thu, 06 Dec 2018 01:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oplyraUjlzT1MdYD0jbSQna4BlEOoZ+ROrl7JO6ZcX4=; b=QCX96gWOCi1IvweM1uDEYuimkCOcRF7+ITWdMJ1/cX/tm7go7g7PjiOOT2DThXg68X oUJoeiHaC9AjOqB99Lc717nDsBjT9MAWCi/KsdCqStANCdXYNgUzqlm9kjXrE9vUwWg0 dnBjBvLFgr43VIcrmgXIskRRE41DcczVCmHhs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oplyraUjlzT1MdYD0jbSQna4BlEOoZ+ROrl7JO6ZcX4=; b=l2gvzWFsOICPh8v5wcHxh57Qo2hMajoFdUQKwrLxbRJRW7ydxdrSES6k2Jmao87uD6 w93BzG7fTN7cZXn5oCzoAlOnNkpPEw3Dw2kRAth8Ntrn3jyx335GNJLheJekfVycze2b jYN9+3ANz5WY8P6DhwlcFR7gOi5gI5Dxf3fPYDwzaw6nl80ZtkdOLJLaqH1f2AxG5Pj5 CLFavJ37vwyI0/woWmzwfPshTski77yGnyOIdoBfusLAfNWH1WjYx77Yuh6jmJXLQE4S dv+UanTMD55i4hkbLlsb+9bwNS0umgmPDOgsRJmYs1QhcdV2o3hodDRdXqZcnCbvNnLO fHWg== X-Gm-Message-State: AA+aEWZ0lEuZ0RazlQQHwN0asOKU2fKhmamHwOljztBlbkIbrQiBCwmQ 6h6fzDgaxYN5p28Dxe2qvenrPsJvkf/PHLE8X0tLsQ== X-Received: by 2002:a67:b245:: with SMTP id s5mr12360073vsh.200.1544087759184; Thu, 06 Dec 2018 01:15:59 -0800 (PST) MIME-Version: 1.0 References: <20181129174700.16585-1-ulf.hansson@linaro.org> <20181129174700.16585-22-ulf.hansson@linaro.org> <20181204184553.GO18262@codeaurora.org> In-Reply-To: <20181204184553.GO18262@codeaurora.org> From: Ulf Hansson Date: Thu, 6 Dec 2018 10:15:23 +0100 Message-ID: Subject: Re: [PATCH v10 21/27] drivers: firmware: psci: Add a helper to attach a CPU to its PM domain To: Lina Iyer Cc: "Rafael J. Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , Linux PM , "Raju P.L.S.S.S.N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Linux ARM , linux-arm-msm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 4 Dec 2018 at 19:45, Lina Iyer wrote: > > On Thu, Nov 29 2018 at 10:50 -0700, Ulf Hansson wrote: > >Introduce a new PSCI DT helper function, psci_dt_attach_cpu(), which takes > >a CPU number as an in-parameter and attaches the CPU's struct device to its > >corresponding PM domain. Additionally, the helper prepares the CPU to be > >power managed via runtime PM, which is the last step needed to enable the > >interaction with the PM domain through the runtime PM callbacks. > > > >Signed-off-by: Ulf Hansson > >--- > > > >Changes in v10: > > - New patch: Replaces "PM / Domains: Add helper functions to > > attach/detach CPUs to/from genpd". > > > >--- > > drivers/firmware/psci/psci.h | 1 + > > drivers/firmware/psci/psci_pm_domain.c | 19 +++++++++++++++++++ > > 2 files changed, 20 insertions(+) > > > >diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h > >index 05af462cc96e..fbc9980dee69 100644 > >--- a/drivers/firmware/psci/psci.h > >+++ b/drivers/firmware/psci/psci.h > >@@ -15,6 +15,7 @@ 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); > >+int psci_dt_attach_cpu(int cpu); > > #else > > static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } > > #endif > >diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c > >index 6c9d6a644c7f..b0fa7da8a0ce 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 > > > >@@ -367,4 +369,21 @@ int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, > > > > return 0; > > } > >+ > >+int psci_dt_attach_cpu(int cpu) > >+{ > >+ struct device *dev = get_cpu_device(cpu); > >+ int ret; > >+ > >+ ret = dev_pm_domain_attach(dev, true); > >+ if (ret) > >+ return ret; > >+ > >+ pm_runtime_irq_safe(dev); > >+ pm_runtime_get_noresume(dev); > >+ pm_runtime_set_active(dev); > You would want to set this only if the CPU is online. Otherwise we will > not power down the domain, if the CPU was never brought online. Nice catch! The platforms I tested this series on brings all their CPUs online during boot, hence I haven't observed the problem. I will post a new version soon to address the problem. Again, thanks for your review! [...] Kind regards Uffe