From patchwork Tue May 29 10:04:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921943 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="JyiIbZ8w"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8Wy5781z9s0W for ; Tue, 29 May 2018 20:06:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933069AbeE2KEe (ORCPT ); Tue, 29 May 2018 06:04:34 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:51601 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932926AbeE2KEa (ORCPT ); Tue, 29 May 2018 06:04:30 -0400 Received: by mail-wm0-f68.google.com with SMTP id r15-v6so11245353wmc.1 for ; Tue, 29 May 2018 03:04:29 -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=RNBwx9Q11leZ2iF4Qt72vYGl8mmLcTrVpjkvTy5woOY=; b=JyiIbZ8wh7YZNGv9pnIcFOD5oafNJ+zlQqcKEE1CZ44YU7y7LlBh6hPVeKDXus0OS4 QlSFN8TsyThEt6g5vVS4rjGTLW7q3a2s1Ccd+NKSn2+apUgEfrWSwY7txaA0whWvepPw 8Jvo6TeOcWPvMYHRH/rhYcsq7k7mKrxs49V9Y= 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=RNBwx9Q11leZ2iF4Qt72vYGl8mmLcTrVpjkvTy5woOY=; b=FY4YxSKEGcnVoIRyj29MxqXU4tkUXwKbJL3dxs3m4eSR/dl5/q6dptp4yFkgNue9y7 5hsoah9rsGVjGHUjI3gx6IBRUNJHeEiXAzCzlDNfb8+6i39J1svgu3peMGrhUqbC6X7S ky5y4+NCTE3cxz4LDxeBR6pQFIYlrYfyTS9AGtmKS8iyVq4DZ3F/77IVXK61fFQ5xr0z mwvd7TbyDA8Le+MW7TRLEiBer7g5PYrZBkptic4urnbiKmuW4ei20ZuukDRxXU+g9rcZ ousDHX27wHOJ1/pfUgm7HCeNM2erQGx3QBF6mnJuXuxwE6H5nw6QttcI2ztB02AY6Moo IkEw== X-Gm-Message-State: ALKqPwfcBggBxabt7zGWNedyIVvsihISEfwKCOPfx+kHUKO8qC4kHRJ0 eFwrwLFLG4OwBzHgVgjwv1CW8Pszr1g= X-Google-Smtp-Source: ADUXVKJMzT40/2PTq1QaebRlZduwZauw+klH1h7H1KOqei5y3Fn80g2TLQ7ZD3gflxPlsLgTXmyeqQ== X-Received: by 2002:a2e:8794:: with SMTP id n20-v6mr10640999lji.38.1527588269201; Tue, 29 May 2018 03:04:29 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:28 -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 v2 1/9] PM / Domains: Drop extern declarations of functions in pm_domain.h Date: Tue, 29 May 2018 12:04:13 +0200 Message-Id: <20180529100421.31022-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 Acked-by: Viresh Kumar --- 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 4e5764083fd8..c847e9a3033d 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 Tue May 29 10:04:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921944 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="ODvLSU72"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8X33wYVz9s0y for ; Tue, 29 May 2018 20:06:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932831AbeE2KGl (ORCPT ); Tue, 29 May 2018 06:06:41 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:40311 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932962AbeE2KEc (ORCPT ); Tue, 29 May 2018 06:04:32 -0400 Received: by mail-wm0-f65.google.com with SMTP id x2-v6so31495033wmh.5 for ; Tue, 29 May 2018 03:04:31 -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=6L5ns3gkirNpoUrGXpNhs9C4kPH2lTxjmYVBDc+TIqo=; b=ODvLSU72CdL3WZ0kO0L8V64poZhA5AicJ3BdDrzysJjL3QfT9Qj3HnqOFaty00Wkdh m37WHsR1z54eq0biQOOGLBrYExpz/gTus7m2nu9SIa+63im685PesrPd3IU2ID+CN1a5 f5PQi6GxXjvECLgl6iuTQ6Z1Rm576hF8Kvy68= 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=6L5ns3gkirNpoUrGXpNhs9C4kPH2lTxjmYVBDc+TIqo=; b=ii+VDrGGku3D5gOKBQ4erHpF3QY7u33Vcpe9LpgtGvOSsjPxmsCL56rFAwQX57m79/ ThHiB027R/rS4AbotcUFr2xyhmOzIH0tiy1/AE/ozNx0DLy2+nCXye8nUvxj+iOfavGE XQcYJ450LAwkgUgqXBM89WacpcLczfI3kjKr0sweA4vIOGNHayY3k6m9xdaJAcOg66Dy /kalub5dIF5rt4kZHhTWl6MC3Bbkct27EXnTX0AJ8AMGbEGreocpnKIX6U1tUmlPq8e7 AAPffWg/nTp5nzlW3YMSLKqX0G0Ax5JeBI0DnrmQJBhKINxxgBEIiXoahBG9abz99pBB NmJw== X-Gm-Message-State: ALKqPwdqVP1tsMkpH7d1mcWXQFv0Op3TvFbVCJMLcyEcsNP4t5qKx65o lBbT9xFaa04UvEvrK2ue9x9r6w== X-Google-Smtp-Source: ADUXVKIRVLeNWQZBxxKOeRoSzbRsA0FXgMtzgFP18JhT/CZbrmv4FIzVa9hxX5iaFYTeDcJ0POaxwg== X-Received: by 2002:a2e:90d4:: with SMTP id o20-v6mr8837526ljg.15.1527588270783; Tue, 29 May 2018 03:04:30 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:30 -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 v2 2/9] PM / Domains: Drop __pm_genpd_add_device() Date: Tue, 29 May 2018 12:04:14 +0200 Message-Id: <20180529100421.31022-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 Reviewed-by: Viresh Kumar --- 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 71a1cc79fbaa..469edb401811 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 c847e9a3033d..79888fb4a81f 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 Tue May 29 10:04:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921945 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="XbWKu90C"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8Xh0tDFz9s0y for ; Tue, 29 May 2018 20:07:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932758AbeE2KGk (ORCPT ); Tue, 29 May 2018 06:06:40 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50370 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932923AbeE2KEd (ORCPT ); Tue, 29 May 2018 06:04:33 -0400 Received: by mail-wm0-f65.google.com with SMTP id t11-v6so38877049wmt.0 for ; Tue, 29 May 2018 03:04:33 -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=dWpX9GjZyWi/EZMjmixZEwXhleiR7O0lE9qJPYWj4B8=; b=XbWKu90Co9xv1XQeW+SUI9hGDj3qL+LaMn+it6SB0ePZT7krrqevsIP5UPCHgRfCZX xzRe6yTkP8kwVvsqBcPMXP99fTT+IMbMH4twcRHqP4Dr63yQypH9quqM8GJfFhqqTsF3 6kHlt7K/Ktj8+o2Yd4Llrr+xMV/HGa1peVeFs= 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=dWpX9GjZyWi/EZMjmixZEwXhleiR7O0lE9qJPYWj4B8=; b=OVIYvFGYRBxbrPKFHtT5aLCzIzGWwi9522urhzRqqXqpkMLpd/uxgzPoSZI+8hwwsi brQ/7xcEQf0LF+yZfEXd7SB6RI3xYBNDL6wEakRgT4KQJwTmow1owhuSRGJQriezsRE3 QfIsv5Lns0bRgl5+DKEQoUSv7q4yc0BTrNOW42wK88/H4W9WBUgJALtscVc5grtnaCh/ AEVB1nqh+WwqbII4wJ/ssKVhewXga6Yad6Fx2GQ6yIObTqG1taIiESiWGyFkSeF0MQXi qGMSDgISyPIeyZiWlPFEAVdQWHPSBlzk1lyVQPDTCDQvGGGhCr/wsZy+GsSRTYz+mF5a gOBQ== X-Gm-Message-State: ALKqPwcHxWaD3wur5kJGKeLYBkrUqUErPGfkOUqb/pJ4ie37QR2yKqOo XeuAjK15s2gWwhOSvpA+pDjGAg== X-Google-Smtp-Source: AB8JxZrRIwXyOABx/Xb4X51c5Lcj3oLNew6FULQYHdusf/qHmEQEeaK/yntpRkYYTI1ZwJwNwYoHxg== X-Received: by 2002:a2e:2e17:: with SMTP id u23-v6mr10592341lju.77.1527588272582; Tue, 29 May 2018 03:04:32 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:31 -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 v2 3/9] PM / Domains: Drop genpd as in-param for pm_genpd_remove_device() Date: Tue, 29 May 2018 12:04:15 +0200 Message-Id: <20180529100421.31022-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 Reviewed-by: Viresh Kumar --- 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 469edb401811..c89b0ad068b7 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 a29362f9ef41..12558044acd4 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 79888fb4a81f..42e0d649e653 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 Tue May 29 10:04:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921935 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="YsanhJIF"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8Tp6pyRz9s0W for ; Tue, 29 May 2018 20:04:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933009AbeE2KEp (ORCPT ); Tue, 29 May 2018 06:04:45 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:50378 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933114AbeE2KEf (ORCPT ); Tue, 29 May 2018 06:04:35 -0400 Received: by mail-wm0-f68.google.com with SMTP id t11-v6so38877301wmt.0 for ; Tue, 29 May 2018 03:04:34 -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=kJ4tREeZdjrEZ1PQJn9PeK0YWZ+ok/gO9XhnLg3/c5c=; b=YsanhJIFu5yoEAf+9u2Mp41yhc2cK15qv3c0zWDkH5U1NdujjSCXHhFWFPs5zGjLlQ TIddHdzm/Sa15svu91vqPz7tOMZL00kUzqN6zVIFKJRXfOOznCHMBkcgiZTipyirZvfA ttITlVq46/WTAIBry5CGD5rrpFkv+WlE9DlRs= 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=kJ4tREeZdjrEZ1PQJn9PeK0YWZ+ok/gO9XhnLg3/c5c=; b=gxG/rjuaEtxxNK4UoHJawZK35Ocz1WS+AGyLY/EV4PcXzft1gf+yCzZ2wJvbZVKtu/ FEsm32LlLZIqoPQBBHAizE0YdZ6Me9JkX/tL5C+Ll6hNm38McvRGLdHtdkMpK9j/7rUO JgYUryRJ1PWjpkDgr0a893O7/kUzIyBcmRbJP8ytgi4HctrCJJae1UjSiFIClmL+3NQf NU9Im5YIxO4D/Z5PRUp5TZbSRfoNZEJnnT5b1jtArFOQclcNe5I7cG6tuF9ckOkE4ZMe 3bcqeOjFXb6Px95VntFYTyZHtJ4NmBstGlbiRbHnTZWDn6hkNoQGxSQIaw9XArW089li a0OQ== X-Gm-Message-State: ALKqPweB1iaXCRjsP8UiubyRFHv+BgGUE6OVbfkpCc/EyIW62EAv3eZD R/2JDgy47HaMjOLvV0YW6a4NNQ== X-Google-Smtp-Source: ADUXVKInPfiT5E08mwa05atlCtkdC9jv2gdESxSgm1xjpp4CXksPDmMOR9EuCK7z+t2hX/AkBD7KFQ== X-Received: by 2002:a2e:8018:: with SMTP id j24-v6mr10481059ljg.92.1527588274274; Tue, 29 May 2018 03:04:34 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:33 -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 v2 4/9] PM / Domains: Drop unused parameter in genpd_allocate_dev_data() Date: Tue, 29 May 2018 12:04:16 +0200 Message-Id: <20180529100421.31022-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 Reviewed-by: Viresh Kumar --- 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 c89b0ad068b7..7ebf7993273a 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 Tue May 29 10:04:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921936 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="IfPceGFx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8Tt4t9Dz9s0y for ; Tue, 29 May 2018 20:04:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933079AbeE2KEr (ORCPT ); Tue, 29 May 2018 06:04:47 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:50388 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933158AbeE2KEh (ORCPT ); Tue, 29 May 2018 06:04:37 -0400 Received: by mail-wm0-f66.google.com with SMTP id t11-v6so38877613wmt.0 for ; Tue, 29 May 2018 03:04:36 -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=Y1uWf3IR6TeX72175kSKMmcxc4JqnYS9BmY6Xhncu1w=; b=IfPceGFxXcTVQGgdrcL9cl12ma8nIHSiNMIRjOOpby+mMIahSYyFnDPuO9EhLdiPEn EfWjXi7XYyrhl+hhMV857ula/5zN7NMSCw7Mv5cyT+8x69M6TBolhHOORER1ojAOUC9B Tf+z6QzzzwrlLkCoa3Iuh0IZssRGk76OjiTL8= 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=Y1uWf3IR6TeX72175kSKMmcxc4JqnYS9BmY6Xhncu1w=; b=Lpak3XMr9PS+ZWZIvdI+02u8LtHE36EvXcfBHcgLo6+fjg11tvlybyC0mAadvSprhE tVRX4IUB70gdK87TIDcipAd7loSNunO7mO8Z2D0nXX1UoiAnhSCg0RGTljc6egQbRIBV 1FvNHHeasszHlhK9Er5/XGDCS8KmWvum2+f/iMEF18CFi+n3nesB7AUN/UaTuszvIbBq BTGTUHF0WLyhd5EMHaTY/Bma7hC4uxcAtH99X0KcuHnLdBE9wYhafpSlPWnvtNuI60Cm C8pIE98U4ts1BacIN7FsnE+yc6M4JHAYctZszjZUS3r0yCoxP6lZlfH3u/lEzSXYunHl GYTg== X-Gm-Message-State: ALKqPwcVKdnOiUqjfMnlIE2NzOrkeUU4T/iXsF9SF3T9crvtUIMRQDL1 QZ+M3oOgcElFQT9smcsimuQZdQ== X-Google-Smtp-Source: AB8JxZoUmLU2Qxs3zDSRshLWegb/wHhLEQDZKm9FgRfhKMHuXHEncGNVpvhTmO+4ay3TZw6CBHNLCQ== X-Received: by 2002:a2e:202:: with SMTP id 2-v6mr9304467ljc.117.1527588275928; Tue, 29 May 2018 03:04:35 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:35 -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 v2 5/9] PM / Domains: dt: Allow power-domain property to be a list of specifiers Date: Tue, 29 May 2018 12:04:17 +0200 Message-Id: <20180529100421.31022-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 PM domain specifiers. Cc: Rob Herring Cc: devicetree@vger.kernel.org Suggested-by: Jon Hunter Signed-off-by: Ulf Hansson Reviewed-by: Rob Herring Reviewed-by: Viresh Kumar --- Changes in v2: - Fixed comments from Geert. Re-worded to "PM domain specifiers" and clarified DT example. --- .../bindings/power/power_domain.txt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/power/power_domain.txt b/Documentation/devicetree/bindings/power/power_domain.txt index 4733f76cbe48..9b387f861aed 100644 --- a/Documentation/devicetree/bindings/power/power_domain.txt +++ b/Documentation/devicetree/bindings/power/power_domain.txt @@ -111,8 +111,8 @@ 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 list of PM domain specifiers, as defined by bindings of + the power controller that is the PM domain provider. Example: @@ -122,9 +122,18 @@ 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@12351000 { + compatible = "foo,i-leak-current"; + reg = <0x12351000 0x1000>; + power-domains = <&power 0>, <&power 1> ; + }; + +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, +the first with index 0 and the second with index 1, of a power controller that +is represented by a node with the label "power. Optional properties: - required-opps: This contains phandle to an OPP node in another device's OPP From patchwork Tue May 29 10:04:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921941 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="baAcQg9k"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8Vm2bq6z9s16 for ; Tue, 29 May 2018 20:05:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932922AbeE2KFf (ORCPT ); Tue, 29 May 2018 06:05:35 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53483 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932921AbeE2KEj (ORCPT ); Tue, 29 May 2018 06:04:39 -0400 Received: by mail-wm0-f68.google.com with SMTP id a67-v6so38674739wmf.3 for ; Tue, 29 May 2018 03:04:38 -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=yQ4ukAh6z4qIZhwwXLKnDtTdeOmHdRuam254ohPML9I=; b=baAcQg9kaTj8nhVtTq8QF2TNt9vxE96Z3+M/1pVcZ82pkYfuX8aiN4+VP81JoiMuF5 qZgVQRq1h4Srun7c3RXORjlRnDOfdhDzI2M11Stqn1dvRMcvH5vVqPK9J5PxmNOZQQ1h sw0pGezezZm6N1vfd4lnGd3Yrb6Eup2QgWwzg= 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=yQ4ukAh6z4qIZhwwXLKnDtTdeOmHdRuam254ohPML9I=; b=OYPLVNIcwoByiufST6wx40shDCUEJZCG+aP7I1NNtqmLqG4nQntJAbE2Cwwd/7nNXK 57iu93wf3NEKpythEs2U10ymAkYMeQXsjqTnH441IPeOo4bdTt0EZNClbDGi5DyWGk9j aDcpcSYwoPyQ+xyF7Vmx/XdnrLpf13epB1WRuiP1K0WOVE91keEPUkm3jWBjL7I+tTDY tYyVL1ALIF+zfCiHIEjmRNL7WmygIYR84013bUAWQDzvVg1TG+ZU9tVsS4l2ACVddX9v u6tTOvk3DZ88RObaUl0JHBxAFOf2iiosWA4N32LqVLRr5cR/lVqvo+0FcVW9W5QEzHKD JMjg== X-Gm-Message-State: ALKqPwcSfiAncLtfSX1GeU19fmhukNDTNm1dBTH9uwcaoTawDC9rIe7P oOyn9KyFEPyrgN8qbV5XjY8piA== X-Google-Smtp-Source: ADUXVKJK3dwOGTKFXDCJ5cCyWrUDOuFQ26iIEK3p1ZsbUBz4yn4KPAjlTTTzBDQDPwalUGToKncNBQ== X-Received: by 2002:a2e:1092:: with SMTP id 18-v6mr5777646ljq.115.1527588277835; Tue, 29 May 2018 03:04:37 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:37 -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 v2 6/9] PM / Domains: Don't attach devices in genpd with multi PM domains Date: Tue, 29 May 2018 12:04:18 +0200 Message-Id: <20180529100421.31022-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 PM domain specifiers, 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 Acked-by: Jon Hunter Tested-by: Jon Hunter --- Changes in v2: - Minor update to changelog to mention "PM domain specifiers" rather than a "list of phandles". --- 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 7ebf7993273a..12a20f21974d 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 Tue May 29 10:04:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921942 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="Nt+688gK"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8WZ18RMz9s0W for ; Tue, 29 May 2018 20:06:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933203AbeE2KFc (ORCPT ); Tue, 29 May 2018 06:05:32 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:54788 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933162AbeE2KEk (ORCPT ); Tue, 29 May 2018 06:04:40 -0400 Received: by mail-wm0-f68.google.com with SMTP id f6-v6so38829185wmc.4 for ; Tue, 29 May 2018 03:04: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=w08o5AzxzvUhesJImVVhXniyXaRI88njLEe6l9D4feg=; b=Nt+688gKBsSkFKU5Lj4526i3xTldcMu+NNHQT001VY29Q1UhsJEzcq61e6xsZ5U88t lDzymVbNVYLpfChI6orDO7EyYlIjp0+SvMBfoTxagUIlJkmCk4o9MYSvosHkwD9CJMqN wUsgRZSLJXP0vfk4CjV+VfhLo8x9JUcI0jbLw= 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=w08o5AzxzvUhesJImVVhXniyXaRI88njLEe6l9D4feg=; b=B6SddBah7ty3i2Dh208BHibYLk1XGyzegiMl5nx9r6I2CMn0YsZMgNPQbWwmnOHBRD +8v2lohXXGrx3rhbvSNsyQBemjI2o6Nx0FVLJT/1yUWdmPYB+u1XP9MLdyt59AHADVsD HKEEOY6XE7nZjlnuigcptTXuBszjTDy1XE5T8p7qdy6JZIvMpHSwqiCOlf9CJK0e2OvK XJPAynAwblUyQydLpkbhxvPuMRmzwHXCSQF2MvIxqnOrMROLiXlxS821f2HXAyCUJiQM R0F6xlYPIvwruDw3/M8rvgKmRVbBsUINHRKpuFgS2nQhUiOt0R1tDPmayXpMsuNM1wcq UryA== X-Gm-Message-State: ALKqPwcpAtgm6uY1IIUsCNFeelBaH3OfJgSFvu0NlKYG2PpWbAjUAZwo XfhjtoIZJrtlpLBnlwaZxkG+FQ== X-Google-Smtp-Source: ADUXVKIJ/QliCcGCC68y02tC/ASzBcOLD+ekXuglYfH8fXzdY1EHNuWngpoa3K2ZAqaHOS1rAnoK6w== X-Received: by 2002:a2e:29cf:: with SMTP id p76-v6mr6408280ljp.12.1527588279396; Tue, 29 May 2018 03:04:39 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:38 -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 v2 7/9] PM / Domains: Split genpd_dev_pm_attach() Date: Tue, 29 May 2018 12:04:19 +0200 Message-Id: <20180529100421.31022-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 Acked-by: Jon Hunter Tested-by: Jon Hunter Reviewed-by: Viresh Kumar --- 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 12a20f21974d..2af99bfcbe3c 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 Tue May 29 10:04:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921939 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="ZZJD24OS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8Vd2Vvvz9s0W for ; Tue, 29 May 2018 20:05:29 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932812AbeE2KF2 (ORCPT ); Tue, 29 May 2018 06:05:28 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53499 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933166AbeE2KEm (ORCPT ); Tue, 29 May 2018 06:04:42 -0400 Received: by mail-wm0-f68.google.com with SMTP id a67-v6so38675195wmf.3 for ; Tue, 29 May 2018 03:04:41 -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=4AKcocpDu8LzFvQQptUzJpFM524E5IXAqb+rjvCBc/c=; b=ZZJD24OSCW897IXk7gN0gsb538Ig7zxjlS3qOtp99xeQh2i2UskamIfmgRM7lHsKnr nK1yXnN+vDVZjpTWJIu0A4f6F9y/IaZnqPl2mFEhssWHHjOog4mQdHPkC/pTV8dnfq0P hIhci/jpMHG3M4VejT5BBJW/dpRmS1mqPOlzI= 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=4AKcocpDu8LzFvQQptUzJpFM524E5IXAqb+rjvCBc/c=; b=i4PpXJIpVm2BNyyog9clNfwvoP/uL+fqIok+nhahoZ0rPkJHuL5xsbdN6M5Kp259U7 P2y0jwTl3xSllGkTXmpY2iDA6XocsKHY+KM79gBOdOmuf6JS3Vh6tXQT7pUYOs4wNLhd fmNv+LPKH7plKQJYkm6jTGeL/AedIQeDeA86MaKbrOsg5DwcYenlRC1kGD8GN82p5eEb TA3nSA1ETsL1+w7h+7usQYJRO56ctcxOVqq0SeF4agpORsbQa4Zjil6sD4mG+CMYYxqV hytoQLKWZxHEQ3BCwQigXjI58DilK6kDzDQ9FbifMadQ2NKufT/xX0HUPphei8pbkP9h mnPA== X-Gm-Message-State: ALKqPweTNMJnkrrBPuhTZ4yMMnnReVXNbFcv/l0R+/kZQFMo6+XFN8yF uUz91GkwCxvuG76ovrywlMctKg== X-Google-Smtp-Source: ADUXVKJeObP68e8ut4WHB00kxNq4iihomAaNX61RuLdxYWga3Fsyujl/yYKCgHyZzeWajzklXEstPw== X-Received: by 2002:a2e:8948:: with SMTP id b8-v6mr10916487ljk.31.1527588281021; Tue, 29 May 2018 03:04:41 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:40 -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 v2 8/9] PM / Domains: Add support for multi PM domains per device to genpd Date: Tue, 29 May 2018 12:04:20 +0200 Message-Id: <20180529100421.31022-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 begin with extending genpd to cope with these kind of configurations. Therefore, add a new exported function genpd_dev_pm_attach_by_id(), which is similar to the existing genpd_dev_pm_attach(), but with the difference that it allows its callers to provide an index to the PM domain that it wants to attach. Note that, genpd_dev_pm_attach_by_id() shall only be called by the driver core / PM core, similar to how the existing dev_pm_domain_attach() makes use of genpd_dev_pm_attach(). However, this is implemented by following changes on top. Because, only one PM domain can be attached per device, genpd needs to create a virtual device that it can attach/detach instead. More precisely, let the new function genpd_dev_pm_attach_by_id() register a virtual struct device via calling device_register(). Then let it attach this device to the corresponding PM domain, rather than the one that is provided by the caller. The actual attaching is done via re-using the existing genpd OF functions. At successful attachment, genpd_dev_pm_attach_by_id() returns the created virtual device, which allows the caller to operate on it to deal with power management. Following changes on top, provides more details in this regards. To deal with detaching of a PM domain for the multiple PM domains case, let's also extend the existing genpd_dev_pm_detach() function, to cover the cleanup of the created virtual device, via make it call device_unregister() on it. In this way, there is no need to introduce a new function to deal with detach for the multiple PM domain case, but instead the existing one is re-used. Signed-off-by: Ulf Hansson --- Changes in v2: - Fixed comments from Jon. Clarified function descriptions and changelog. --- drivers/base/power/domain.c | 80 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 8 ++++ 2 files changed, 88 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 2af99bfcbe3c..2b496d79159d 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,67 @@ 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, creates a virtual device and attaches it to the retrieved + * pm_domain ops. To deal with detaching of the virtual device, the ->detach() + * callback in the struct dev_pm_domain are assigned to genpd_dev_pm_detach(). + * + * Returns the created virtual device if successfully attached PM domain, NULL + * when the device don't need a PM domain, else an ERR_PTR() in case of + * failures. If a power-domain exists for the device, but cannot be found or + * turned on, then ERR_PTR(-EPROBE_DEFER) is returned 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", }, { } @@ -2457,6 +2531,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 42e0d649e653..82458e8e2e01 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 Tue May 29 10:04:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 921938 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="ecNCmJsd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40w8VZ4YD2z9s0W for ; Tue, 29 May 2018 20:05:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932700AbeE2KFY (ORCPT ); Tue, 29 May 2018 06:05:24 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40377 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932793AbeE2KEo (ORCPT ); Tue, 29 May 2018 06:04:44 -0400 Received: by mail-wm0-f68.google.com with SMTP id x2-v6so31496930wmh.5 for ; Tue, 29 May 2018 03:04:43 -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=26+aFTQcf8NYAmN2QvZuXP7NjVudzK5mSbJ9dDrOxiE=; b=ecNCmJsd9VWpG9MyI81I76oV8PL2zVXy1+IbyAK/4m8OCwk65hXqimHuJsJCkwrs2S sqUpv45VVoDFv4ZGBXkOy9Tn38tMC/XRQAkR6OAUrDoe79YKVhiQMYrSbMdSpjAKOAtw en1I3yRfN7ewd4NHbeWuXayE7NZdmPC9kqQTg= 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=26+aFTQcf8NYAmN2QvZuXP7NjVudzK5mSbJ9dDrOxiE=; b=QecSn0a9i1DsMy8ZwE4xO6Z6hq7oTcnirmJ54K5uK3Mmzb1piwGCNlwIZbDNL0Zevl e2WYhLM2/Zh+HmUXQkQbAnREW6WfG1EQntJYKJxBk8i7aPcb3AwmlRXraHUZDj3G68d5 6AOFQcwq8HSrC49BZ/iHOuEwGX1HRRkS8uen5wQyeZghxEbmQuXt1nCB6YLYxam6mEJc eajtnKDoKEA38HFfHRw7XYIsiEG/7Fc1AVbDraEBOuxZMd2OT8is8XO7sg+TmKppXX/F PZryCZen3MY9ktr+RqUIsnTqEEmcdldXWwoqQ4owNgVsCgKra9bOOsx0Zw16Z8AqV5q0 W5YQ== X-Gm-Message-State: ALKqPwdKdZfC8zoUGhmoYMoXhHMpXQLhxHgCxd91OLbW8eRl5q/Mm++8 UT79qSk1sxSt2FJ3GRWSWwh42dmbf7E= X-Google-Smtp-Source: AB8JxZpdKnqoAWTu+BP+iszsxtDqrRYbPFEHVsqKwfrR620KrIjmigbhfpmoIg+HE8fwIvl1uRExAg== X-Received: by 2002:a2e:9d95:: with SMTP id c21-v6mr10799697ljj.89.1527588282866; Tue, 29 May 2018 03:04:42 -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 e21-v6sm2561718lfg.74.2018.05.29.03.04.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:04:42 -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 v2 9/9] PM / Domains: Add dev_pm_domain_attach_by_id() to manage multi PM domains Date: Tue, 29 May 2018 12:04:21 +0200 Message-Id: <20180529100421.31022-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529100421.31022-1-ulf.hansson@linaro.org> References: <20180529100421.31022-1-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 --- Changes in v2: - Fixed comments from Jon. Clarified function descriptions/changelog and return ERR_PTR(-EEXIST) in case a PM domain is already assigned. - Fix build error when CONFIG_PM is unset. --- drivers/base/power/common.c | 43 ++++++++++++++++++++++++++++++++++--- include/linux/pm_domain.h | 7 ++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index 7ae62b6355b8..5e5ea0c239de 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -116,14 +116,51 @@ 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. + * @dev: Device to attach. + * @index: The index of the PM domain. + * + * As @dev may only be attached to a single PM domain, the backend PM domain + * provider creates a virtual device to attach instead. If attachment succeeds, + * the ->detach() callback in the struct dev_pm_domain are assigned by the + * corresponding backend attach function, as to deal with detaching of the + * created virtual device. + * + * This function should typically be invoked by a driver during the probe phase, + * in case its device requires power management through multiple PM domains. The + * driver may benefit from using the received device, to configure device-links + * towards its original device. Depending on the use-case and if needed, the + * links may be dynamically changed by the driver, which allows it to control + * the power to the PM domains independently from each other. + * + * Callers must ensure proper synchronization of this function with power + * management callbacks. + * + * Returns the virtual created device when successfully attached to its PM + * domain, NULL in case @dev don't need a PM domain, else an ERR_PTR(). + * Note that, to detach the returned virtual device, the driver shall call + * dev_pm_domain_detach() on it, typically during the remove phase. + */ +struct device *dev_pm_domain_attach_by_id(struct device *dev, + unsigned int index) +{ + if (dev->pm_domain) + return ERR_PTR(-EEXIST); + + 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. + * This functions will reverse the actions from dev_pm_domain_attach() and + * dev_pm_domain_attach_by_id(), thus it detaches @dev from its PM domain. + * Typically it should be invoked during the remove phase, either from + * subsystem level code or from drivers. * * 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 82458e8e2e01..9206a4fef9ac 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) {}