From patchwork Thu Nov 29 17:46:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 152445 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2672582ljp; Thu, 29 Nov 2018 09:47:45 -0800 (PST) X-Received: by 2002:a19:26ce:: with SMTP id m197mr1599709lfm.23.1543513665442; Thu, 29 Nov 2018 09:47:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513665; cv=none; d=google.com; s=arc-20160816; b=DMqhcHyAtmVnkXS3lJwxtCODEeujvSaf8RWZB1JAven+uwT+bBdae33QoP2GsEhYXr W11y4CxPbi29TR0Se4y+Krf5d2Iq2RFmpxntwPxlS6Bjc9bUy1wU+GwLlpCVuKb8ZAlk F2k/5yqjbbYTAiG9lElvhe3TeUOtDSdJiau/xp4lUYRCMEiImsMGaTXMMAakXzwHm1G2 i4ASqoPL1KkT6CT52F6gf5FFpztGNBPDGSKl8SCReCQRQBE0NT6LrjvnvGAga6iDUvPX OopXb+KAv0toWNRcK2Gw7pVSmGf7xvmhWng259XtQtr6Z0iMRrx00TzODGatHHrpA/SC oKUg== 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=3t2vyFxKLnIeRsykykXv6/9Q0Qsu6Nz8v2F0owXov5U=; b=mNcmZzW0wig78OlmztxdIK7Ei59bhz/TQJjGKCFE/zWX7zi+f/qJANJnIIuJdL92Sq wPz7CIRxYnKyVQ/Lg41q1ax6KAN+1rEwMTQMT/MI6VNYNp7ieM1PJ6oljLxT/lRI4TzQ b1CvYX9tYMZrHi4yM/6VMvblWkZ8Vt0zYaqxsRtfsPrtFRD/YYlUGAB+WZouQUrx81Wl 2tbVIHeYb2IHE3aYV08bpPNvPmqPpkSPqOMGo9JmtW9i16sV84hZw/vPrvPXuyvVYnRV XsoHdnO2CqHuKarAXEunHL+p2M1QEDG9hhWtYKE7XyCvCg/c9+VYf5O8smzDGeSlMN/H Az/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E6m0EYyl; 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 h10-v6sor1808861ljf.39.2018.11.29.09.47.45 for (Google Transport Security); Thu, 29 Nov 2018 09:47:45 -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=E6m0EYyl; 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=3t2vyFxKLnIeRsykykXv6/9Q0Qsu6Nz8v2F0owXov5U=; b=E6m0EYylUq2Ibxx2zDTr+getdoAXAblt6NGSV5xnZi+anl5A9e/0htj8QZMpMF512l AiV1KScgBl/lv5TQptuE8nTGJrfWqH+rbUj9OP94f7ViYYpIkOCdbPfmx5cVlgvm0xTc KI2xBQgpTUrEt020geOSiKICiHi1PKWxfnZGs= 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=3t2vyFxKLnIeRsykykXv6/9Q0Qsu6Nz8v2F0owXov5U=; b=eHR4FsETDhFbWddx5IS7cj//Qc+qqd53AkBXdQP36yWBiUvS+wfMwNWC/LkDGIo96g tFVna2otLT536jExVJFnmtNaM/3x7E6EACL0gNj5Kd25W0I7aPkfKySUgOENjs5BLO9R jApl/aRxUdD+4xN/FmNm5qN0YemXZlUnJLMT7r2OfdzFevx26Xx4UViaWJ9AS2EH4cgL XKljeBVsnIq9Ajog7ia22LT9qBP4r+6fSjTNETJoE3nirGHIanI0dHCoAFgP1nDcbs3s SYgA3mY/jJJBrYzLXiolJD0oN55mRKen39l8h3yzfB03DnXG9F7gYU/wFN6ooRKN2plQ s5Cw== X-Gm-Message-State: AA+aEWaOq9EOjC4oy2Tns6cL9vDYhbq8hFbOxlEdwnwzVPdipwXuF+FI dNDDH2GvVo/WD6V+BYwzxyrOE8Ky X-Google-Smtp-Source: AFSGD/UWoMttAcw7++cNF/9mzFJwLwWDB8IZ1w4ykCERuAaM1HAR5F/wdmCVK3YlklPIHBfdzF9PKg== X-Received: by 2002:a2e:1551:: with SMTP id 17-v6mr1736107ljv.68.1543513665097; Thu, 29 Nov 2018 09:47:45 -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 j76-v6sm393983ljb.12.2018.11.29.09.47.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:44 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 21/27] drivers: firmware: psci: Add a helper to attach a CPU to its PM domain Date: Thu, 29 Nov 2018 18:46:54 +0100 Message-Id: <20181129174700.16585-22-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-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 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(+) -- 2.17.1 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); + pm_runtime_enable(dev); + + return 0; +} #endif