From patchwork Fri May 18 10:31:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PsO2ofpj"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPfW5Ztjz9s2k for ; Fri, 18 May 2018 20:33:55 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752536AbeERKbx (ORCPT ); Fri, 18 May 2018 06:31:53 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:43780 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752419AbeERKbu (ORCPT ); Fri, 18 May 2018 06:31:50 -0400 Received: by mail-lf0-f67.google.com with SMTP id n18-v6so13181449lfh.10 for ; Fri, 18 May 2018 03:31:49 -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=RPhKlg5dvZpNzCvJuZWRD2r+4coRtPy1rCugMyAhTzk=; b=PsO2ofpjBYwRdxZ4mbNfW3jvo4qW66HdVRL1oy5hkczANz5wED/fh4nygCXznJDCVB gXTIj1v3XJGCy6bfvilz4jjO7heoLOis7WWlOG4MbNrVpZjwZqxcsxFvVmJEHGzrZGHG ImHFI2D4yiStK+g8m2PHzqEuzhbM1geaq4thY= 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=RPhKlg5dvZpNzCvJuZWRD2r+4coRtPy1rCugMyAhTzk=; b=EFNGX2SSklbTnXy7OdtoQxFEoWcfO/081rtrPBxV54s5PBo04ARgj7CdeMv4ghtpRI KXn93qONUZ51rIW8SXN+04eB1GLHoucoyZyIhIiv0V/rWm7xehxAZc0zobNUsM5mWQ8A 1BVuqEvo+lwB1dq2PMXQlXnwyc/KLDLiBNbrCh/Hy11//zuVFYO6k/E0SC/aowqAD1eV F0L6p9FzFowL67BPPlQHlrYKmy5bjBqDr+WAjLVDbCuAOPYCC2DpfIz8p4jvj7fLd9Sa IaPyqA5EeWNs1LoCU3g9ZKgmiJA8Qb8Z6BNnaDARIDt8itqb5ZijV/+zrz4Z9yyl4BNh 6cfw== X-Gm-Message-State: ALKqPwfN/tOlCcBHVOz7KQQ2VqxOT43Yj4aqnniy3ndFPPnfx2xnDA1x bwjF1B6cf8n5nYBdlTHn+7Tpxw== X-Google-Smtp-Source: AB8JxZr2hIzXfxG7I9BP9a8HDr3UDRB+UeMrabZpIjsCL9BeUCmjLFKw73Tl8Kv+ZETL48PRIrtilQ== X-Received: by 2002:a2e:9f56:: with SMTP id v22-v6mr5253112ljk.42.1526639508531; Fri, 18 May 2018 03:31:48 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:47 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 1/9] PM / Domains: Drop extern declarations of functions in pm_domain.h Date: Fri, 18 May 2018 12:31:22 +0200 Message-Id: <1526639490-12167-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Using "extern" to declare a function in a public header file is somewhat pointless, but also doesn't hurt. However, to make all the function declarations in pm_domain.h to be consistent, let's drop the use of "extern". Signed-off-by: Ulf Hansson --- include/linux/pm_domain.h | 51 +++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 4e57640..c847e9a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -143,21 +143,17 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) return to_gpd_data(dev->power.subsys_data->domain_data); } -extern int __pm_genpd_add_device(struct generic_pm_domain *genpd, - struct device *dev, - struct gpd_timing_data *td); - -extern int pm_genpd_remove_device(struct generic_pm_domain *genpd, - struct device *dev); -extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, - struct generic_pm_domain *new_subdomain); -extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, - struct generic_pm_domain *target); -extern int pm_genpd_init(struct generic_pm_domain *genpd, - struct dev_power_governor *gov, bool is_off); -extern int pm_genpd_remove(struct generic_pm_domain *genpd); -extern int dev_pm_genpd_set_performance_state(struct device *dev, - unsigned int state); +int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, + struct gpd_timing_data *td); +int pm_genpd_remove_device(struct generic_pm_domain *genpd, struct device *dev); +int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, + struct generic_pm_domain *new_subdomain); +int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, + struct generic_pm_domain *target); +int pm_genpd_init(struct generic_pm_domain *genpd, + struct dev_power_governor *gov, bool is_off); +int pm_genpd_remove(struct generic_pm_domain *genpd); +int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -215,8 +211,8 @@ static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, } #ifdef CONFIG_PM_GENERIC_DOMAINS_SLEEP -extern void pm_genpd_syscore_poweroff(struct device *dev); -extern void pm_genpd_syscore_poweron(struct device *dev); +void pm_genpd_syscore_poweroff(struct device *dev); +void pm_genpd_syscore_poweron(struct device *dev); #else static inline void pm_genpd_syscore_poweroff(struct device *dev) {} static inline void pm_genpd_syscore_poweron(struct device *dev) {} @@ -240,14 +236,13 @@ int of_genpd_add_provider_simple(struct device_node *np, int of_genpd_add_provider_onecell(struct device_node *np, struct genpd_onecell_data *data); void of_genpd_del_provider(struct device_node *np); -extern int of_genpd_add_device(struct of_phandle_args *args, - struct device *dev); -extern int of_genpd_add_subdomain(struct of_phandle_args *parent, - struct of_phandle_args *new_subdomain); -extern struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); -extern int of_genpd_parse_idle_states(struct device_node *dn, - struct genpd_power_state **states, int *n); -extern unsigned int of_genpd_opp_to_performance_state(struct device *dev, +int of_genpd_add_device(struct of_phandle_args *args, struct device *dev); +int of_genpd_add_subdomain(struct of_phandle_args *parent, + struct of_phandle_args *new_subdomain); +struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); +int of_genpd_parse_idle_states(struct device_node *dn, + struct genpd_power_state **states, int *n); +unsigned int of_genpd_opp_to_performance_state(struct device *dev, struct device_node *opp_node); int genpd_dev_pm_attach(struct device *dev); @@ -304,9 +299,9 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */ #ifdef CONFIG_PM -extern int dev_pm_domain_attach(struct device *dev, bool power_on); -extern void dev_pm_domain_detach(struct device *dev, bool power_off); -extern void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); +int dev_pm_domain_attach(struct device *dev, bool power_on); +void dev_pm_domain_detach(struct device *dev, bool power_off); +void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); #else static inline int dev_pm_domain_attach(struct device *dev, bool power_on) { From patchwork Fri May 18 10:31:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LCBFqQ9u"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPg46KMXz9s29 for ; Fri, 18 May 2018 20:34:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752467AbeERKeK (ORCPT ); Fri, 18 May 2018 06:34:10 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33085 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752506AbeERKbv (ORCPT ); Fri, 18 May 2018 06:31:51 -0400 Received: by mail-lf0-f68.google.com with SMTP id h9-v6so13238597lfi.0 for ; Fri, 18 May 2018 03:31:50 -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=tR0PqVnyqpAIqwNNOSqwkpFdimOYd4PJO2b808P7gkQ=; b=LCBFqQ9uL7zZ7tojJ9j4HjEgPfSroxwirJNmmwZ/8UXKLxJvGImZuUZe3VZdYwaizx Zp+V+zgQR66pIvvKmXtUriWDzs1UC5/QjaVJjpeFWYt3UNd+HneZ7N01piHHflW4q76y cXjctC1TLCyKFXbraEN902WQHHbM2AFJ/DibU= 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=tR0PqVnyqpAIqwNNOSqwkpFdimOYd4PJO2b808P7gkQ=; b=OaJbV3hex1tFylYU1j1mKb8vxHGpmj6Z5BW+mSEm8hRpc6ix8bpyob5SeIaUBL6PJZ mRmpO3zyg6Dnavu/0rIp5Ej455efuj5TUmn89Eq8eicxKqbpjsKsuzApRM9xx/3QA7Ht OLCUoMmpT/PSp3CFxsOKqG0B0XzpOEoQ+IXwFhrwDC5KXfHCWyITvScnKthhwmkVsZQf PQkbaqSjngcxkicM+ECTmDEVhGiJQx6TJ45wdh9zqeuxiBcukBfKJRkfpBd6L52TUPML CLTTEV77sOvf0Acj5LnqV6JXEAbsRYvR18y4E1G44MWURdtfIBmyoPzgbpw970d40Dwm TBew== X-Gm-Message-State: ALKqPwddGpzMVrvQGKxZX1o3dSsSt9qxY0D330R5I6xglYeO2kF9E55W QwOvvhD1BmCh/Ea6yXcARqaNwKJrCwg= X-Google-Smtp-Source: AB8JxZrBvFRNg3Bh/JNsQLtIhPmiYn7cpO3FRnyTqs5tj2c5eZHv2zm6Qe64JwBRGHy380U6qOwofw== X-Received: by 2002:a2e:97d6:: with SMTP id m22-v6mr5601140ljj.102.1526639509845; Fri, 18 May 2018 03:31:49 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:49 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 2/9] PM / Domains: Drop __pm_genpd_add_device() Date: Fri, 18 May 2018 12:31:23 +0200 Message-Id: <1526639490-12167-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org There are still a few non-DT existing users of genpd, however neither of them uses __pm_genpd_add_device(), hence let's drop it. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 10 ++++------ include/linux/pm_domain.h | 14 +++----------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index da6c886..d58aee3 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1414,23 +1414,21 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, } /** - * __pm_genpd_add_device - Add a device to an I/O PM domain. + * pm_genpd_add_device - Add a device to an I/O PM domain. * @genpd: PM domain to add the device to. * @dev: Device to be added. - * @td: Set of PM QoS timing parameters to attach to the device. */ -int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, - struct gpd_timing_data *td) +int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) { int ret; mutex_lock(&gpd_list_lock); - ret = genpd_add_device(genpd, dev, td); + ret = genpd_add_device(genpd, dev, NULL); mutex_unlock(&gpd_list_lock); return ret; } -EXPORT_SYMBOL_GPL(__pm_genpd_add_device); +EXPORT_SYMBOL_GPL(pm_genpd_add_device); static int genpd_remove_device(struct generic_pm_domain *genpd, struct device *dev) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index c847e9a..79888fb 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -143,8 +143,7 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) return to_gpd_data(dev->power.subsys_data->domain_data); } -int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, - struct gpd_timing_data *td); +int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev); int pm_genpd_remove_device(struct generic_pm_domain *genpd, struct device *dev); int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *new_subdomain); @@ -163,9 +162,8 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) { return ERR_PTR(-ENOSYS); } -static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd, - struct device *dev, - struct gpd_timing_data *td) +static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, + struct device *dev) { return -ENOSYS; } @@ -204,12 +202,6 @@ static inline int dev_pm_genpd_set_performance_state(struct device *dev, #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) #endif -static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, - struct device *dev) -{ - return __pm_genpd_add_device(genpd, dev, NULL); -} - #ifdef CONFIG_PM_GENERIC_DOMAINS_SLEEP void pm_genpd_syscore_poweroff(struct device *dev); void pm_genpd_syscore_poweron(struct device *dev); From patchwork Fri May 18 10:31:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="S+B602X/"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPfX6DZbz9s33 for ; Fri, 18 May 2018 20:33:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752680AbeERKdy (ORCPT ); Fri, 18 May 2018 06:33:54 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35973 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752528AbeERKbx (ORCPT ); Fri, 18 May 2018 06:31:53 -0400 Received: by mail-lf0-f68.google.com with SMTP id t129-v6so13215843lff.3 for ; Fri, 18 May 2018 03:31:52 -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 :mime-version:content-transfer-encoding; bh=mrlhryGd1zUtOvLg/ngqC5LqE3Y8XGBVqRFwggWHaTs=; b=S+B602X/KlaCWP6uFlXFWrmH7FqhohWe3/D8x92HusdtLldYaRE5dNHWk6+tDLjw5C oYLPx+Xo29TLaZl3/QXuTkXBywtGOLhZMRhcGM7MgV1IhMqKuTmDVFtRCpmG/jUeV1Q9 I262o1K0k4KxyM0u1qXUJLFjbbC03HiUS2hC4= 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:mime-version:content-transfer-encoding; bh=mrlhryGd1zUtOvLg/ngqC5LqE3Y8XGBVqRFwggWHaTs=; b=SLs5IXuTT7oZC2erGidOsMVSJwxoPFwcT69hyUKj8KvivmWUcmwX/2lxEyVEd8kTvF QdkW9Duc/hs1A3U8wHwAGZo2DSLBEqDAK79fXlC71jMAqxStmWBpX+JO+N+L+9ViyKh5 vd04W+oVFpB0PtLiEwshM8XiRQTTl9tcnjX/db0Jko2a+j4QOHd3hwq5LrvmvoAML9Sb JmNrIICxtqlGf+951nqv4Zf290F0pCUJHNNq923vqm+nGCR7LSwxOYjknYvTzj1iStmV DQ+e1BAt6ykQ4zkp4aTmPxuAgBOmSjm44sFs3nunQ9uoX/cy7QNgvPoQTjrC/eZqons/ YK4A== X-Gm-Message-State: ALKqPwfgHvMV0csEXNq0b0UMPCd3RLi5PIHWhMt6aD+vs+q8g/QAEMOm pyT/yYuUmNxY8bxiuoVagkddTQ== X-Google-Smtp-Source: AB8JxZoSU9iG6mBQQ90xm13k33Urc/Ocnxvp2NGBAuipMgL7V/kLR5ZV9/9m953bZZMGjTSF1DXxZQ== X-Received: by 2002:a19:e99b:: with SMTP id j27-v6mr19990694lfk.93.1526639511483; Fri, 18 May 2018 03:31:51 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:50 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, Alex Deucher , =?utf-8?q?Christian_K=C3=B6n?= =?utf-8?q?ig?= , David Zhou Subject: [PATCH 3/9] PM / Domains: Drop genpd as in-param for pm_genpd_remove_device() Date: Fri, 18 May 2018 12:31:24 +0200 Message-Id: <1526639490-12167-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org There is no need to pass a genpd struct to pm_genpd_remove_device(), as we already have the information about the PM domain (genpd) through the device structure. Additionally, we don't allow to remove a PM domain from a device, other than the one it may have assigned to it, so really it does not make sense to have a separate in-param for it. For these reason, drop it and update the current only call to pm_genpd_remove_device() from amdgpu_acp. Cc: Alex Deucher Cc: Christian König Cc: David (ChunMing) Zhou Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 2 +- include/linux/pm_domain.h | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index d58aee3..f08fa15 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1475,13 +1475,13 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, /** * pm_genpd_remove_device - Remove a device from an I/O PM domain. - * @genpd: PM domain to remove the device from. * @dev: Device to be removed. */ -int pm_genpd_remove_device(struct generic_pm_domain *genpd, - struct device *dev) +int pm_genpd_remove_device(struct device *dev) { - if (!genpd || genpd != genpd_lookup_dev(dev)) + struct generic_pm_domain *genpd = genpd_lookup_dev(dev); + + if (!genpd) return -EINVAL; return genpd_remove_device(genpd, dev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c index a29362f..1255804 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c @@ -513,7 +513,7 @@ static int acp_hw_fini(void *handle) if (adev->acp.acp_genpd) { for (i = 0; i < ACP_DEVS ; i++) { dev = get_mfd_cell_dev(adev->acp.acp_cell[i].name, i); - ret = pm_genpd_remove_device(&adev->acp.acp_genpd->gpd, dev); + ret = pm_genpd_remove_device(dev); /* If removal fails, dont giveup and try rest */ if (ret) dev_err(dev, "remove dev from genpd failed\n"); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 79888fb..42e0d64 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -144,7 +144,7 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) } int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev); -int pm_genpd_remove_device(struct generic_pm_domain *genpd, struct device *dev); +int pm_genpd_remove_device(struct device *dev); int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *new_subdomain); int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, @@ -167,8 +167,7 @@ static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, { return -ENOSYS; } -static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd, - struct device *dev) +static inline int pm_genpd_remove_device(struct device *dev) { return -ENOSYS; } From patchwork Fri May 18 10:31:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="QhH30i3S"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPfR3D6Wz9s29 for ; Fri, 18 May 2018 20:33:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648AbeERKdi (ORCPT ); Fri, 18 May 2018 06:33:38 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36868 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752550AbeERKby (ORCPT ); Fri, 18 May 2018 06:31:54 -0400 Received: by mail-lf0-f68.google.com with SMTP id r2-v6so13228914lff.4 for ; Fri, 18 May 2018 03:31:53 -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=AO4Qa5M//3zUMqNYe4J+qW+VkFpbLbZ8jACmAJcz7Ao=; b=QhH30i3SOCfTPWugwTRcLUG4jGu3LrakT+Ht5Tl6Iu/NIoOsmY+Ez7M6cvPp2fTNUX xIQ2xUfZHF/gTxY5lrsw3WWdC6X0AiO5XobD6ucPlCogJAEc0X9naah89eBONQ4Ii7Jb CPuWUDz7ufjuIFJvrSjguJMus08rbIrkKca0c= 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=AO4Qa5M//3zUMqNYe4J+qW+VkFpbLbZ8jACmAJcz7Ao=; b=gC9gWfzOC6hTaEXouCkMo1O9kq6IRXRpe4HhQ82VKXqBFnPBMDn6IgMvxZLsXZhYno We5jUYf4MGQ0Ne1w9fLg9b/s/oWF400JRBd80J4f3s6HxJQa/SUeUhGSar/7DNHxzQAX BThkhHPeORR6D5iV69YubZwebBV5XYIe7WUswCNNADQST3xoNI7WIMAg8AolFW/ssdsy d6BOqEt2+8RYhnerldCRe6L9tMTL8CMpL4G+d/zdwIynPh7Mu18ZYpvs6Yur4QEQljHf TSQ+qnuljiLyABJ0mxIxQJtn/jELHRBDeRku5oKijWjq97nPQRjbwlor6Y1HR2Z44iom 8/LA== X-Gm-Message-State: ALKqPwf5pI2Wuj9TP0fh8MROZE93l1rj7hYSLTixx/VDHUhVpvM3LT4/ 21LXrqvXvr74p2zzRTdCTiin9g== X-Google-Smtp-Source: AB8JxZoAvL2q68KhQPs7hD56Svq93grsBsKVTW6zSin50UT48+5IZqw15RiJjN6ZpZkrhdZgAzn7sg== X-Received: by 2002:a19:d763:: with SMTP id o96-v6mr19825161lfg.89.1526639512770; Fri, 18 May 2018 03:31:52 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:52 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 4/9] PM / Domains: Drop unused parameter in genpd_allocate_dev_data() Date: Fri, 18 May 2018 12:31:25 +0200 Message-Id: <1526639490-12167-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org The in-parameter struct generic_pm_domain *genpd to genpd_allocate_dev_data() is unused, so let's drop it. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index f08fa15..050ce07 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1316,7 +1316,6 @@ EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron); #endif /* CONFIG_PM_SLEEP */ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, - struct generic_pm_domain *genpd, struct gpd_timing_data *td) { struct generic_pm_domain_data *gpd_data; @@ -1385,7 +1384,7 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev)) return -EINVAL; - gpd_data = genpd_alloc_dev_data(dev, genpd, td); + gpd_data = genpd_alloc_dev_data(dev, td); if (IS_ERR(gpd_data)) return PTR_ERR(gpd_data); From patchwork Fri May 18 10:31:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="aS1+0njr"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPdT5Fp9z9s29 for ; Fri, 18 May 2018 20:33:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752645AbeERKb7 (ORCPT ); Fri, 18 May 2018 06:31:59 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33096 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752604AbeERKb4 (ORCPT ); Fri, 18 May 2018 06:31:56 -0400 Received: by mail-lf0-f68.google.com with SMTP id h9-v6so13238876lfi.0 for ; Fri, 18 May 2018 03:31:55 -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=SVjBUAD346aCNJoRL9NhmrACmsm4gOdU4wLskwp7B4Q=; b=aS1+0njrQYgYF6HuGy79UcjoA4O7XOlS7mbORzzyWjWKy+R0+FKk/eP59UjDqN2SI1 pILFYSSfDa3562021cObIbp81BE+cN3jb+XRc+I0ADSVUmwLfW1jz034u4bkirRl7k/U YMM4SvC4y4g0cLWaMNk5EveBU4L/nN6vkrrEQ= 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=SVjBUAD346aCNJoRL9NhmrACmsm4gOdU4wLskwp7B4Q=; b=uZVvSP/nvMYquW2Pj/v4cf7RyeKMkdO79858DfqiJArCMHlhy7ZbwJrUFnZAjXG+PC OHHbt5ZLdDrAh46TW+CPwsfWDc0XSSomAG6m7xx3sqpeFBz3dpIRHrQJoSAH+j2DoUmk idroB7gXJFJSGpfHzY357jsZfTqYVxyVkAC6PFbb24IMPG66OeK0frDnNj5jKQn/61uz 0fioUWZfjUChG1jGwq1TmV9f+CGvprGdEaWy6dDv62wxZLncmgZoU66auEv+Rh3QaZt/ dYT2Ab0t+mTtOjaBZHyDHFaFlD4rTjpDVUKgggtI7pLh0Kr42JE2M6i/Q6ONSIM7mLg9 RdvQ== X-Gm-Message-State: ALKqPwfzXsRkXJcyYJQbGmIknDHrobnUAs0t0s6CT+q+F1PhlJuPR5ag N3Or6Sf1k2UrvHwL/sx4djnnWA== X-Google-Smtp-Source: AB8JxZpQtY/3mk2mu2NoKbovx7CxdsdaBwJLVXwKQnQEVUBi57Jtmko0CQE781wg3SUvya9Yvn69tw== X-Received: by 2002:a19:df55:: with SMTP id q21-v6mr766042lfj.56.1526639514100; Fri, 18 May 2018 03:31:54 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:53 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 5/9] PM / Domains: dt: Allow power-domain property to be a list of phandles Date: Fri, 18 May 2018 12:31:26 +0200 Message-Id: <1526639490-12167-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org To be able to describe topologies where devices are partitioned across multiple power domains, let's extend the power-domain property to allow being a list of phandles. Cc: Rob Herring Cc: devicetree@vger.kernel.org Suggested-by: Jon Hunter Signed-off-by: Ulf Hansson --- .../devicetree/bindings/power/power_domain.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/power/power_domain.txt b/Documentation/devicetree/bindings/power/power_domain.txt index 4733f76..b27ae7f 100644 --- a/Documentation/devicetree/bindings/power/power_domain.txt +++ b/Documentation/devicetree/bindings/power/power_domain.txt @@ -111,8 +111,9 @@ Example 3: ==PM domain consumers== Required properties: - - power-domains : A phandle and PM domain specifier as defined by bindings of - the power controller specified by phandle. + - power-domains : A phandle and PM domain specifier, or a list of phandles, as + defined by bindings of the power controller specified by + phandle. Example: @@ -122,9 +123,16 @@ Example: power-domains = <&power 0>; }; -The node above defines a typical PM domain consumer device, which is located -inside a PM domain with index 0 of a power controller represented by a node -with the label "power". + leaky-device@12350000 { + compatible = "foo,i-leak-current"; + reg = <0x12350000 0x1000>; + power-domains = <&power0 0>, <&power1 0> ; + }; + +The first example above defines a typical PM domain consumer device, which is +located inside a PM domain with index 0 of a power controller represented by a +node with the label "power". In the second example the consumer device are +partitioned across two PM domains. Optional properties: - required-opps: This contains phandle to an OPP node in another device's OPP From patchwork Fri May 18 10:31:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="X6z3qWhc"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPd14jfZz9s29 for ; Fri, 18 May 2018 20:32:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752664AbeERKcB (ORCPT ); Fri, 18 May 2018 06:32:01 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34676 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752622AbeERKb5 (ORCPT ); Fri, 18 May 2018 06:31:57 -0400 Received: by mail-lf0-f66.google.com with SMTP id x145-v6so1197047lff.1 for ; Fri, 18 May 2018 03:31:56 -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=vOMTRNhtUSt3+UjyP2nlZZlBgPAv7fyJ4Yo7WaId5rQ=; b=X6z3qWhcSmJF+BSaodWX2IwnI3TRkHuarLbkzzirLp3//Dl9XxFE83X3QsOzt9yZiz peNtDxrr+dFdYbrd52h8rF6rGrmfWaXRfHz9e6gtDAcqJydGFysqeKxKvgXUqy+YJxws 3OyVD6b3NAZTLYqc4ooYxqkk6oH/d6/l7r/QY= 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=vOMTRNhtUSt3+UjyP2nlZZlBgPAv7fyJ4Yo7WaId5rQ=; b=Hmha4MPjaTA/rm7E+tNcqtF5NPJm4ly2gj5yrevWI6LTLzI0h5fM+26o8u/Np2I+A+ G5HhcdNfg7+JVSkrGWstCO7lF/w9UkvC8YmmIaWGSYd52lASlq6I3oMGg/JDPR8/cH67 HOZzZ1bOy+W1eRUjnoxJ8zJ6nVVlF1+vZIXHmt6pNggSoLwBRtTheenKG3sTuyxKYA3j ibndo2iSq2Z/y70i7RZi/H2PvhphdjDjqZbs6lkAu+8WTlSaO94qR7tfPTpN3sIk80lW 4u6P5Ji8HKjYqflri+YHD95dicDhpXn37yXU5vtNArHAXgZqhi8O7X9ujaZh9W9kMDDV SLig== X-Gm-Message-State: ALKqPweI2mXUiiuYDn1kP9YnNcm1QJ0LP7ZqRoguW6WCCmWGfxS7z42a D9ay/GLeekyy2Se0d4yS7L2TAQ== X-Google-Smtp-Source: AB8JxZoDjYfqlw1Mw1sfEZLrtPeCkPK3p/6U38zWopdmXmNDtTS+kkQ9UAI7Jk8m+uL+2pifybjtUA== X-Received: by 2002:a19:17e9:: with SMTP id 102-v6mr13768283lfx.19.1526639515471; Fri, 18 May 2018 03:31:55 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:54 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 6/9] PM / Domains: Don't attach devices in genpd with multi PM domains Date: Fri, 18 May 2018 12:31:27 +0200 Message-Id: <1526639490-12167-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org The power-domain DT property may now contain a list of phandles, which represents that a device are partitioned across multiple PM domains. This leads to a new situation in genpd_dev_pm_attach(), as only one PM domain can be attached per device. To remain things simple for the most common configuration, when a single PM domain is used, let's treat the multiple PM domain case as being specific. In other words, let's change genpd_dev_pm_attach() to check for multiple PM domains and prevent it from attach any PM domain for this case. Instead, leave this to be managed separately, from following changes to genpd. Cc: Rob Herring Cc: devicetree@vger.kernel.org Suggested-by: Jon Hunter Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 050ce07..4597e1c 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2229,10 +2229,10 @@ static void genpd_dev_pm_sync(struct device *dev) * attaches the device to retrieved pm_domain ops. * * Returns 1 on successfully attached PM domain, 0 when the device don't need a - * PM domain or a negative error code in case of failures. Note that if a - * power-domain exists for the device, but it cannot be found or turned on, - * then return -EPROBE_DEFER to ensure that the device is not probed and to - * re-try again later. + * PM domain or when multiple power-domains exists for it, else a negative error + * code. Note that if a power-domain exists for the device, but it cannot be + * found or turned on, then return -EPROBE_DEFER to ensure that the device is + * not probed and to re-try again later. */ int genpd_dev_pm_attach(struct device *dev) { @@ -2243,10 +2243,18 @@ int genpd_dev_pm_attach(struct device *dev) if (!dev->of_node) return 0; + /* + * Devices with multiple PM domains must be attached separately, as we + * can only attach one PM domain per device. + */ + if (of_count_phandle_with_args(dev->of_node, "power-domains", + "#power-domain-cells") != 1) + return 0; + ret = of_parse_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells", 0, &pd_args); if (ret < 0) - return 0; + return ret; mutex_lock(&gpd_list_lock); pd = genpd_get_from_provider(&pd_args); From patchwork Fri May 18 10:31:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="OuwhZT3r"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPcN5KB8z9s33 for ; Fri, 18 May 2018 20:32:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbeERKcD (ORCPT ); Fri, 18 May 2018 06:32:03 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33099 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752627AbeERKb6 (ORCPT ); Fri, 18 May 2018 06:31:58 -0400 Received: by mail-lf0-f66.google.com with SMTP id h9-v6so13239049lfi.0 for ; Fri, 18 May 2018 03:31:57 -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=sU8YoiDnS9KwTX3yb8JNQw8Hu2BQlzK2ChcOcpzCzno=; b=OuwhZT3re7bOZzUyx1ZCKemt3sE86/MtuzIsxvjP2qcsOl7FYo1gFL82H8qsU20Sh9 /655EcFClraw10GEeLB/WMdCKbKBF4gF7pB6b6fBy5DbR8mP1R1kcQPNfmpZq5eXQ9mv 0/+PKS9QyhZ4CCnWMMXHBsZbX/pKvv4+3EQZc= 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=sU8YoiDnS9KwTX3yb8JNQw8Hu2BQlzK2ChcOcpzCzno=; b=jcniUW26c5BpWwi0THT9+AV4XdLuhKRZk6hmh4gh94hYgySaDHtXRfIGKuks11w7/6 wk+DaP41O9qzcTX0rmAmHFKGX94p8t+GCL6bqQixRWNavg4DWqN1PLe6zhWsMI15/DtW +SLqeA6SC79J8H/sN7mG5YxzXUjCGAxvy66J/lYrEZ2pUr8iQO6CjCNL8RozQgB8sghA PM1qbcPEGAzSDNGBGQwlwj/k28hZuaOD7r8A5ncvTHnwBT8EvZIhwngigh73AJgSMDec YWqncrKn6DuScfTJWp/QKMQEcePZrT2lNKyfMGojTYCQcGcSy+QZ1TO7MWX/2Cs68ft7 fIXQ== X-Gm-Message-State: ALKqPwfDCTl4zrfCSPaK8hYeNcjSCtLH5zQFCDoBtMLidAyeBBOqtV7/ Mplue0qHQ9t8CEr+AZ7vlQ6WdQ== X-Google-Smtp-Source: AB8JxZog55BJ5wlqBKzzx6/qzmykM0WVtUMCUbPNJ3dKVeDfFA03E89utYZkZf18WbLt9/JtdUezVg== X-Received: by 2002:a2e:4d5d:: with SMTP id a90-v6mr5576174ljb.86.1526639516836; Fri, 18 May 2018 03:31:56 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:56 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 7/9] PM / Domains: Split genpd_dev_pm_attach() Date: Fri, 18 May 2018 12:31:28 +0200 Message-Id: <1526639490-12167-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org To extend genpd to deal with allowing multiple PM domains per device, some of the code in genpd_dev_pm_attach() can be re-used. Let's prepare for this by moving some of the code into a sub-function. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 60 +++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4597e1c..d538640 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2221,38 +2221,15 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } -/** - * genpd_dev_pm_attach - Attach a device to its PM domain using DT. - * @dev: Device to attach. - * - * Parse device's OF node to find a PM domain specifier. If such is found, - * attaches the device to retrieved pm_domain ops. - * - * Returns 1 on successfully attached PM domain, 0 when the device don't need a - * PM domain or when multiple power-domains exists for it, else a negative error - * code. Note that if a power-domain exists for the device, but it cannot be - * found or turned on, then return -EPROBE_DEFER to ensure that the device is - * not probed and to re-try again later. - */ -int genpd_dev_pm_attach(struct device *dev) +static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np, + unsigned int index) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; int ret; - if (!dev->of_node) - return 0; - - /* - * Devices with multiple PM domains must be attached separately, as we - * can only attach one PM domain per device. - */ - if (of_count_phandle_with_args(dev->of_node, "power-domains", - "#power-domain-cells") != 1) - return 0; - - ret = of_parse_phandle_with_args(dev->of_node, "power-domains", - "#power-domain-cells", 0, &pd_args); + ret = of_parse_phandle_with_args(np, "power-domains", + "#power-domain-cells", index, &pd_args); if (ret < 0) return ret; @@ -2290,6 +2267,35 @@ int genpd_dev_pm_attach(struct device *dev) return ret ? -EPROBE_DEFER : 1; } + +/** + * genpd_dev_pm_attach - Attach a device to its PM domain using DT. + * @dev: Device to attach. + * + * Parse device's OF node to find a PM domain specifier. If such is found, + * attaches the device to retrieved pm_domain ops. + * + * Returns 1 on successfully attached PM domain, 0 when the device don't need a + * PM domain or when multiple power-domains exists for it, else a negative error + * code. Note that if a power-domain exists for the device, but it cannot be + * found or turned on, then return -EPROBE_DEFER to ensure that the device is + * not probed and to re-try again later. + */ +int genpd_dev_pm_attach(struct device *dev) +{ + if (!dev->of_node) + return 0; + + /* + * Devices with multiple PM domains must be attached separately, as we + * can only attach one PM domain per device. + */ + if (of_count_phandle_with_args(dev->of_node, "power-domains", + "#power-domain-cells") != 1) + return 0; + + return __genpd_dev_pm_attach(dev, dev->of_node, 0); +} EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); static const struct of_device_id idle_state_match[] = { From patchwork Fri May 18 10:31:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XfaL9NAc"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPf26Td9z9s29 for ; Fri, 18 May 2018 20:33:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752467AbeERKdA (ORCPT ); Fri, 18 May 2018 06:33:00 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:45035 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752644AbeERKb7 (ORCPT ); Fri, 18 May 2018 06:31:59 -0400 Received: by mail-lf0-f68.google.com with SMTP id h197-v6so13182618lfg.11 for ; Fri, 18 May 2018 03:31:59 -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=Xufj7MGpsD5staIyz3w3w6bZYYrOOfrLdPdsC/ARxQ8=; b=XfaL9NAcTTyxaFgCw1yf13SBWWlnK1Cm3QMV9BnJtI4NPTzxh0RhZhh8p80eKuOmAX ivYNRwLmbV0nPeXdckjpqbbZp4x0N1kPRsnfO3ww1EPh40hR33i8JVOVtrrBDHFhwoTy wpJjVPvTEs5X71FKQa34Hq5MJ23NnoPXLvtyM= 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=Xufj7MGpsD5staIyz3w3w6bZYYrOOfrLdPdsC/ARxQ8=; b=dMzLGBzG8vREv/g63NJh3Wt3ki5Y6db9sqlp/uVBVDM7LOx7N/EgYO2c0npCPDHgyx cKGrgIsCJaibrk7+hp4npYIRTTMbSXd8YXNnCD1wD33pnLfrqsuTYcBp2huwJyhOEBD1 L2O5SqyrcYH1RDAZyW9byGMK9bnBqu5VitcuOm65NdVb8wig5MMwOgLBqqEwXzUVphRi mNf+ZOm1WZh1mS6vjmmmj8VM54Wr4LlJRIVZxTQO3Wff4Fdrog9q3UMIHC4JQW8mA1jw 2QoL0xk3w8P72d+70H//NFm7Z+4+kB7o7NITnP18GffILmA/S/qXrblaWUpHZOFW/8SS 0lxw== X-Gm-Message-State: ALKqPweZb1FQ6rDwv+KYOnnP2acDcqknJ4us6tErqBUGmaKSnix9RzE8 j+K2Zi9bFZWpGPWEgS1amPq4fA== X-Google-Smtp-Source: AB8JxZq7mpM973JWrWfZxrFD1GsHz4vCBEQ6o2rdyZ/tLmF2MV4ZidskyfEYzlHs0uv7qZ2Ai2/B8Q== X-Received: by 2002:a2e:83d7:: with SMTP id s23-v6mr5316082ljh.34.1526639518196; Fri, 18 May 2018 03:31:58 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:57 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 8/9] PM / Domains: Add support for multi PM domains per device to genpd Date: Fri, 18 May 2018 12:31:29 +0200 Message-Id: <1526639490-12167-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org To support devices being partitioned across multiple PM domains, let's start by extending genpd to cope with these configurations. More precisely, add a new exported function, genpd_dev_pm_attach_by_id(), similar to genpd_dev_pm_attach(), but the new function also allows the caller to provide an index to what PM domain it wants to attach. Furthermore, let genpd register a new virtual struct device via calling device_register() and attach it to the corresponding PM domain, which is looked up via calling the existing genpd OF functions. Note that the new device is needed, because only one PM domain can be attached per device. At successful attachment, genpd_dev_pm_attach_by_id() returns the new device, allowing the caller to operate on it to deal with power management. To deal with detaching of a PM domain for multiple PM domain case, we can still re-use the existing genpd_dev_pm_detach() function, although we need to extend it to cover cleanup of the earlier registered device, via calling device_unregister(). An important note, genpd_dev_pm_attach_by_id() shall only be called by the driver core / PM core, similar to how genpd_dev_pm_attach() is used. Following changes deploys this. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 79 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 8 +++++ 2 files changed, 87 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index d538640..ffeb6ea 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2171,6 +2171,15 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) } EXPORT_SYMBOL_GPL(of_genpd_remove_last); +static void genpd_release_dev(struct device *dev) +{ + kfree(dev); +} + +static struct bus_type genpd_bus_type = { + .name = "genpd", +}; + /** * genpd_dev_pm_detach - Detach a device from its PM domain. * @dev: Device to detach. @@ -2208,6 +2217,10 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off) /* Check if PM domain can be powered off after removing this device. */ genpd_queue_power_off_work(pd); + + /* Unregister the device if it was created by genpd. */ + if (dev->bus == &genpd_bus_type) + device_unregister(dev); } static void genpd_dev_pm_sync(struct device *dev) @@ -2298,6 +2311,66 @@ int genpd_dev_pm_attach(struct device *dev) } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); +/** + * genpd_dev_pm_attach_by_id() - Attach a device to one of its PM domain. + * @dev: Device to attach. + * @index: The index of the PM domain. + * + * Parse device's OF node to find a PM domain specifier at the provided @index. + * If such is found, allocates a new device and attaches it to retrieved + * pm_domain ops. + * + * Returns the allocated device if successfully attached PM domain, NULL when + * the device don't need a PM domain or have a single PM domain, else PTR_ERR() + * in case of failures. Note that if a power-domain exists for the device, but + * cannot be found or turned on, then return PTR_ERR(-EPROBE_DEFER) to ensure + * that the device is not probed and to re-try again later. + */ +struct device *genpd_dev_pm_attach_by_id(struct device *dev, + unsigned int index) +{ + struct device *genpd_dev; + int num_domains; + int ret; + + if (!dev->of_node) + return NULL; + + /* Deal only with devices using multiple PM domains. */ + num_domains = of_count_phandle_with_args(dev->of_node, "power-domains", + "#power-domain-cells"); + if (num_domains < 2 || index >= num_domains) + return NULL; + + /* Allocate and register device on the genpd bus. */ + genpd_dev = kzalloc(sizeof(*genpd_dev), GFP_KERNEL); + if (!genpd_dev) + return ERR_PTR(-ENOMEM); + + dev_set_name(genpd_dev, "genpd:%u:%s", index, dev_name(dev)); + genpd_dev->bus = &genpd_bus_type; + genpd_dev->release = genpd_release_dev; + + ret = device_register(genpd_dev); + if (ret) { + kfree(genpd_dev); + return ERR_PTR(ret); + } + + /* Try to attach the device to the PM domain at the specified index. */ + ret = __genpd_dev_pm_attach(genpd_dev, dev->of_node, index); + if (ret < 1) { + device_unregister(genpd_dev); + return ret ? ERR_PTR(ret) : NULL; + } + + pm_runtime_set_active(genpd_dev); + pm_runtime_enable(genpd_dev); + + return genpd_dev; +} +EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id); + static const struct of_device_id idle_state_match[] = { { .compatible = "domain-idle-state", }, { } @@ -2456,6 +2529,12 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev, } EXPORT_SYMBOL_GPL(of_genpd_opp_to_performance_state); +static int __init genpd_bus_init(void) +{ + return bus_register(&genpd_bus_type); +} +core_initcall(genpd_bus_init); + #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */ diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 42e0d64..82458e8 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -237,6 +237,8 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev, struct device_node *opp_node); int genpd_dev_pm_attach(struct device *dev); +struct device *genpd_dev_pm_attach_by_id(struct device *dev, + unsigned int index); #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ static inline int of_genpd_add_provider_simple(struct device_node *np, struct generic_pm_domain *genpd) @@ -282,6 +284,12 @@ static inline int genpd_dev_pm_attach(struct device *dev) return 0; } +static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev, + unsigned int index) +{ + return NULL; +} + static inline struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) { From patchwork Fri May 18 10:31:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 916181 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="kxVJatCT"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nPdJ4hTJz9s29 for ; Fri, 18 May 2018 20:32:52 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752650AbeERKcu (ORCPT ); Fri, 18 May 2018 06:32:50 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33107 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752451AbeERKcB (ORCPT ); Fri, 18 May 2018 06:32:01 -0400 Received: by mail-lf0-f66.google.com with SMTP id h9-v6so13239207lfi.0 for ; Fri, 18 May 2018 03:32:00 -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=ZcMqktTgVrlFyixB7rDxIq6FvIIB/LXvMKcWVjQol/I=; b=kxVJatCTSOTh6Lqrzf13A9ATud2vAtbdxmpWBmHDU+gZilYcWS6t3W00VFtGFU8MhJ 5if4Hj6N8ZvupxeajqUt0/yT+yo09zUveZc8pxSdi/Yf9oYpcf6QOrCLb1sCedEkGzZF RZMebIvCf3WyaYEqg6vw0G7NPwYV8bqgy1qK4= 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=ZcMqktTgVrlFyixB7rDxIq6FvIIB/LXvMKcWVjQol/I=; b=tPuHf8+ruVJhy0WP5NPGMJa6hFr+E54Z2i9hGH1rjmhdrUfBaleVVziWvi7a3y/7NW cA60WcV3l/VCpF2pVRlG0H4gse55KvyyltQgYBvtD9woijs7dfEzi0lboNXx1cz709sR KYdDbVLrySTKsNLxplK6xS3LT44SYBKqsWETAA6p3CkNeObCdCdG1FJwWgUJOpx7eft+ 0lgnwKi8j1cNS2BT0PSaUICkTYsryvGSU1Sr+DmmNIkhxbmni87lmqsFiDJI7zaNa11B rdt/c165DFQWl1Gj2TVU2ve5OGGjpMwq6CiJd0XjGNbYTHU9bQgjBM3Fcu9de92fvBfk qbxw== X-Gm-Message-State: ALKqPwcqrJfpr6IH1KA6rTySqXMJLWImTyFx7X4f567CPTrS0rdE58dl FIKJUBAR1PLwVzj4qBeAus84/Q== X-Google-Smtp-Source: AB8JxZon1aIya6jSBJzU5mKTem807xN1/o7m1G6xeqQKKjiIDloQLl2HRjnxC44xXsTrdBKzbIT0GA== X-Received: by 2002:a2e:2402:: with SMTP id k2-v6mr5751500ljk.20.1526639519449; Fri, 18 May 2018 03:31:59 -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 u14-v6sm393447lfk.55.2018.05.18.03.31.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 03:31:58 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 9/9] PM / Domains: Add dev_pm_domain_attach_by_id() to manage multi PM domains Date: Fri, 18 May 2018 12:31:30 +0200 Message-Id: <1526639490-12167-10-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org The existing dev_pm_domain_attach() function, allows a single PM domain to be attached per device. To be able to support devices that are partitioned across multiple PM domains, let's introduce a new interface, dev_pm_domain_attach_by_id(). The dev_pm_domain_attach_by_id() returns a new allocated struct device with the corresponding attached PM domain. This enables for example a driver to operate on the new device from a power management point of view. The driver may then also benefit from using the received device, to set up so called device-links towards its original device. Depending on the situation, these links may then be dynamically changed. The new interface is typically called by drivers during their probe phase, in case they manages devices which uses multiple PM domains. If that is the case, the driver also becomes responsible of managing the detaching of the PM domains, which typically should be done at the remove phase. Detaching is done by calling the existing dev_pm_domain_detach() function and for each of the received devices from dev_pm_domain_attach_by_id(). Note, currently its only genpd that supports multiple PM domains per device, but dev_pm_domain_attach_by_id() can easily by extended to cover other PM domain types, if/when needed. Signed-off-by: Ulf Hansson --- drivers/base/power/common.c | 33 ++++++++++++++++++++++++++++++++- include/linux/pm_domain.h | 7 +++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index 7ae62b6..d3db974 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -117,13 +117,44 @@ int dev_pm_domain_attach(struct device *dev, bool power_on) EXPORT_SYMBOL_GPL(dev_pm_domain_attach); /** + * dev_pm_domain_attach_by_id - Attach a device to one of its PM domains. + * @index: The index of the PM domain. + * @dev: Device to attach. + * + * As @dev may only be attached to a single PM domain, the backend PM domain + * provider should create a virtual device to attach instead. As attachment + * succeeds, the ->detach() callback in the struct dev_pm_domain should be + * assigned by the corresponding backend attach function. + * + * This function should typically be invoked from drivers during probe phase. + * Especially for those that manages devices which requires power management + * through more than one PM domain. + * + * Callers must ensure proper synchronization of this function with power + * management callbacks. + * + * Returns the virtual attached device in case successfully attached PM domain, + * NULL in case @dev don't need a PM domain, else a PTR_ERR(). + */ +struct device *dev_pm_domain_attach_by_id(struct device *dev, + unsigned int index) +{ + if (dev->pm_domain) + return NULL; + + return genpd_dev_pm_attach_by_id(dev, index); +} +EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id); + +/** * dev_pm_domain_detach - Detach a device from its PM domain. * @dev: Device to detach. * @power_off: Used to indicate whether we should power off the device. * * This functions will reverse the actions from dev_pm_domain_attach() and thus * try to detach the @dev from its PM domain. Typically it should be invoked - * from subsystem level code during the remove phase. + * during the remove phase, either from subsystem level code or from drivers in + * case attaching was done through dev_pm_domain_attach_by_id. * * Callers must ensure proper synchronization of this function with power * management callbacks. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 82458e8..493ce67 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -299,6 +299,8 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) #ifdef CONFIG_PM int dev_pm_domain_attach(struct device *dev, bool power_on); +struct device *dev_pm_domain_attach_by_id(struct device *dev, + unsigned int index); void dev_pm_domain_detach(struct device *dev, bool power_off); void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); #else @@ -306,6 +308,11 @@ static inline int dev_pm_domain_attach(struct device *dev, bool power_on) { return 0; } +static inline struct device *dev_pm_domain_attach_by_id(struct device *dev, + unsigned int index); +{ + return NULL; +} static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} static inline void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd) {}