* [RFC PATCH 0/2] Introduce multi PM domains helpers
@ 2020-03-02 20:56 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:56 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: gregkh, khilman, ulf.hansson, linux-pm, linux-kernel, shawnguo,
s.hauer, kernel, festevam, linux-imx, daniel.baluta,
pierre-louis.bossart, alsa-devel, linux-arm-kernel, aisheng.dong,
shengjiu.wang, paul.olaru, ranjani.sridharan, Daniel Baluta
From: Daniel Baluta <daniel.baluta@nxp.com>
i.MX8QXP/i.MX8QM has IPs that need multiple power domains to be up
in order to work. In order to help drivers, we introduce multi PM
domains helpers that are able to activate/deactivate multi PM domains.
First patch introduces the helpers and second patch demonstrates how
a driver can use them instead of hardcoding the PM domains handling.
Daniel Baluta (2):
PM / domains: Introduce multi PM domains helpers
ASoC: SOF: Use multi PM domains helpers
drivers/base/power/common.c | 93 +++++++++++++++++++++++++++++++++++++
include/linux/pm_domain.h | 19 ++++++++
sound/soc/sof/imx/imx8.c | 54 +++------------------
3 files changed, 118 insertions(+), 48 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* [RFC PATCH 0/2] Introduce multi PM domains helpers
@ 2020-03-02 20:56 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:56 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: aisheng.dong, daniel.baluta, ulf.hansson, festevam, alsa-devel,
linux-pm, gregkh, s.hauer, khilman, ranjani.sridharan,
linux-kernel, Daniel Baluta, pierre-louis.bossart, paul.olaru,
linux-imx, kernel, shawnguo, shengjiu.wang, linux-arm-kernel
From: Daniel Baluta <daniel.baluta@nxp.com>
i.MX8QXP/i.MX8QM has IPs that need multiple power domains to be up
in order to work. In order to help drivers, we introduce multi PM
domains helpers that are able to activate/deactivate multi PM domains.
First patch introduces the helpers and second patch demonstrates how
a driver can use them instead of hardcoding the PM domains handling.
Daniel Baluta (2):
PM / domains: Introduce multi PM domains helpers
ASoC: SOF: Use multi PM domains helpers
drivers/base/power/common.c | 93 +++++++++++++++++++++++++++++++++++++
include/linux/pm_domain.h | 19 ++++++++
sound/soc/sof/imx/imx8.c | 54 +++------------------
3 files changed, 118 insertions(+), 48 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* [RFC PATCH 0/2] Introduce multi PM domains helpers
@ 2020-03-02 20:56 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:56 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: aisheng.dong, daniel.baluta, ulf.hansson, festevam, alsa-devel,
linux-pm, gregkh, s.hauer, khilman, ranjani.sridharan,
linux-kernel, Daniel Baluta, pierre-louis.bossart, paul.olaru,
linux-imx, kernel, shawnguo, shengjiu.wang, linux-arm-kernel
From: Daniel Baluta <daniel.baluta@nxp.com>
i.MX8QXP/i.MX8QM has IPs that need multiple power domains to be up
in order to work. In order to help drivers, we introduce multi PM
domains helpers that are able to activate/deactivate multi PM domains.
First patch introduces the helpers and second patch demonstrates how
a driver can use them instead of hardcoding the PM domains handling.
Daniel Baluta (2):
PM / domains: Introduce multi PM domains helpers
ASoC: SOF: Use multi PM domains helpers
drivers/base/power/common.c | 93 +++++++++++++++++++++++++++++++++++++
include/linux/pm_domain.h | 19 ++++++++
sound/soc/sof/imx/imx8.c | 54 +++------------------
3 files changed, 118 insertions(+), 48 deletions(-)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
2020-03-02 20:56 ` Daniel Baluta
(?)
@ 2020-03-02 20:56 ` Daniel Baluta
-1 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:56 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: gregkh, khilman, ulf.hansson, linux-pm, linux-kernel, shawnguo,
s.hauer, kernel, festevam, linux-imx, daniel.baluta,
pierre-louis.bossart, alsa-devel, linux-arm-kernel, aisheng.dong,
shengjiu.wang, paul.olaru, ranjani.sridharan, Daniel Baluta
From: Daniel Baluta <daniel.baluta@nxp.com>
This patch introduces helpers support for multi PM domains.
API consists of:
1) dev_multi_pm_attach - powers up all PM domains associated with a given
device. Because we can attach one PM domain per device, we create
virtual devices (children of initial device) and associate PM domains
one per virtual device.
2) dev_multi_pm_detach - detaches all virtual devices from PM domains
attached with.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
drivers/base/power/common.c | 93 +++++++++++++++++++++++++++++++++++++
include/linux/pm_domain.h | 19 ++++++++
2 files changed, 112 insertions(+)
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
index bbddb267c2e6..a90cc6b476e4 100644
--- a/drivers/base/power/common.c
+++ b/drivers/base/power/common.c
@@ -228,3 +228,96 @@ void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd)
device_pm_check_callbacks(dev);
}
EXPORT_SYMBOL_GPL(dev_pm_domain_set);
+
+/**
+ * dev_multi_pm_attach - power up device associated power domains
+ * @dev: The device used to lookup the PM domains
+ *
+ * Parse device's OF node to find all PM domains specifiers. For each power
+ * domain found, create a virtual device and associate it with the
+ * current power domain.
+ *
+ * This function should typically be invoked by a driver during the
+ * probe phase, in the case its device requires power management through
+ * multiple PM domains.
+ *
+ * Returns a pointer to @dev_multi_pm_domain_data if successfully attached PM
+ * domains, NULL if 0 or 1 PM domains specified, else an ERR_PTR() in case of
+ * failures.
+ */
+struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
+{
+ struct dev_multi_pm_domain_data *mpd, *retp;
+ int num_domains;
+ int i;
+
+ num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
+ "#power-domain-cells");
+ if (num_domains < 2)
+ return NULL;
+
+ mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
+ if (!mpd)
+ return ERR_PTR(-ENOMEM);
+
+ mpd->dev = dev;
+ mpd->num_domains = num_domains;
+
+ mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
+ sizeof(*mpd->virt_devs),
+ GFP_KERNEL);
+ if (!mpd->virt_devs)
+ return ERR_PTR(-ENOMEM);
+
+ mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
+ sizeof(*mpd->links), GFP_KERNEL);
+ if (!mpd->links)
+ return ERR_PTR(-ENOMEM);
+
+ for (i = 0; i < mpd->num_domains; i++) {
+ mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
+ if (IS_ERR(mpd->virt_devs[i])) {
+ retp = (struct dev_multi_pm_domain_data *)
+ mpd->virt_devs[i];
+ goto exit_unroll_pm;
+ }
+ mpd->links[i] = device_link_add(dev, mpd->virt_devs[i],
+ DL_FLAG_STATELESS |
+ DL_FLAG_PM_RUNTIME |
+ DL_FLAG_RPM_ACTIVE);
+ if (!mpd->links[i]) {
+ retp = ERR_PTR(-ENOMEM);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ goto exit_unroll_pm;
+ }
+ }
+ return mpd;
+
+exit_unroll_pm:
+ while (--i >= 0) {
+ device_link_del(mpd->links[i]);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ }
+
+ return retp;
+}
+EXPORT_SYMBOL(dev_multi_pm_attach);
+
+/**
+ * dev_multi_pm_detach - Detach a device from its PM domains.
+ * Each multi power domain is attached to a virtual children device
+ *
+ * @mpd: multi power domains data, contains the association between
+ * virtul device and PM domain
+ *
+ */
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd)
+{
+ int i;
+
+ for (i = 0; i < mpd->num_domains; i++) {
+ device_link_del(mpd->links[i]);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ }
+}
+EXPORT_SYMBOL(dev_multi_pm_detach);
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 9ec78ee53652..5bcb35150af2 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -183,6 +183,13 @@ struct generic_pm_domain_data {
void *data;
};
+struct dev_multi_pm_domain_data {
+ struct device *dev; /* parent device */
+ struct device **virt_devs; /* virtual children links */
+ struct device_link **links; /* links parent <-> virtual children */
+ int num_domains;
+};
+
#ifdef CONFIG_PM_GENERIC_DOMAINS
static inline struct generic_pm_domain_data *to_gpd_data(struct pm_domain_data *pdd)
{
@@ -369,18 +376,27 @@ 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 dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev);
struct device *dev_pm_domain_attach_by_id(struct device *dev,
unsigned int index);
struct device *dev_pm_domain_attach_by_name(struct device *dev,
const char *name);
void dev_pm_domain_detach(struct device *dev, bool power_off);
int dev_pm_domain_start(struct device *dev);
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd);
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)
{
return 0;
}
+
+struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
+{
+ return NULL;
+}
+
static inline struct device *dev_pm_domain_attach_by_id(struct device *dev,
unsigned int index)
{
@@ -396,6 +412,9 @@ static inline int dev_pm_domain_start(struct device *dev)
{
return 0;
}
+
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd) {}
+
static inline void dev_pm_domain_set(struct device *dev,
struct dev_pm_domain *pd) {}
#endif
--
2.17.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
@ 2020-03-02 20:56 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:56 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: aisheng.dong, daniel.baluta, ulf.hansson, festevam, alsa-devel,
linux-pm, gregkh, s.hauer, khilman, ranjani.sridharan,
linux-kernel, Daniel Baluta, pierre-louis.bossart, paul.olaru,
linux-imx, kernel, shawnguo, shengjiu.wang, linux-arm-kernel
From: Daniel Baluta <daniel.baluta@nxp.com>
This patch introduces helpers support for multi PM domains.
API consists of:
1) dev_multi_pm_attach - powers up all PM domains associated with a given
device. Because we can attach one PM domain per device, we create
virtual devices (children of initial device) and associate PM domains
one per virtual device.
2) dev_multi_pm_detach - detaches all virtual devices from PM domains
attached with.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
drivers/base/power/common.c | 93 +++++++++++++++++++++++++++++++++++++
include/linux/pm_domain.h | 19 ++++++++
2 files changed, 112 insertions(+)
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
index bbddb267c2e6..a90cc6b476e4 100644
--- a/drivers/base/power/common.c
+++ b/drivers/base/power/common.c
@@ -228,3 +228,96 @@ void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd)
device_pm_check_callbacks(dev);
}
EXPORT_SYMBOL_GPL(dev_pm_domain_set);
+
+/**
+ * dev_multi_pm_attach - power up device associated power domains
+ * @dev: The device used to lookup the PM domains
+ *
+ * Parse device's OF node to find all PM domains specifiers. For each power
+ * domain found, create a virtual device and associate it with the
+ * current power domain.
+ *
+ * This function should typically be invoked by a driver during the
+ * probe phase, in the case its device requires power management through
+ * multiple PM domains.
+ *
+ * Returns a pointer to @dev_multi_pm_domain_data if successfully attached PM
+ * domains, NULL if 0 or 1 PM domains specified, else an ERR_PTR() in case of
+ * failures.
+ */
+struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
+{
+ struct dev_multi_pm_domain_data *mpd, *retp;
+ int num_domains;
+ int i;
+
+ num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
+ "#power-domain-cells");
+ if (num_domains < 2)
+ return NULL;
+
+ mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
+ if (!mpd)
+ return ERR_PTR(-ENOMEM);
+
+ mpd->dev = dev;
+ mpd->num_domains = num_domains;
+
+ mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
+ sizeof(*mpd->virt_devs),
+ GFP_KERNEL);
+ if (!mpd->virt_devs)
+ return ERR_PTR(-ENOMEM);
+
+ mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
+ sizeof(*mpd->links), GFP_KERNEL);
+ if (!mpd->links)
+ return ERR_PTR(-ENOMEM);
+
+ for (i = 0; i < mpd->num_domains; i++) {
+ mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
+ if (IS_ERR(mpd->virt_devs[i])) {
+ retp = (struct dev_multi_pm_domain_data *)
+ mpd->virt_devs[i];
+ goto exit_unroll_pm;
+ }
+ mpd->links[i] = device_link_add(dev, mpd->virt_devs[i],
+ DL_FLAG_STATELESS |
+ DL_FLAG_PM_RUNTIME |
+ DL_FLAG_RPM_ACTIVE);
+ if (!mpd->links[i]) {
+ retp = ERR_PTR(-ENOMEM);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ goto exit_unroll_pm;
+ }
+ }
+ return mpd;
+
+exit_unroll_pm:
+ while (--i >= 0) {
+ device_link_del(mpd->links[i]);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ }
+
+ return retp;
+}
+EXPORT_SYMBOL(dev_multi_pm_attach);
+
+/**
+ * dev_multi_pm_detach - Detach a device from its PM domains.
+ * Each multi power domain is attached to a virtual children device
+ *
+ * @mpd: multi power domains data, contains the association between
+ * virtul device and PM domain
+ *
+ */
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd)
+{
+ int i;
+
+ for (i = 0; i < mpd->num_domains; i++) {
+ device_link_del(mpd->links[i]);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ }
+}
+EXPORT_SYMBOL(dev_multi_pm_detach);
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 9ec78ee53652..5bcb35150af2 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -183,6 +183,13 @@ struct generic_pm_domain_data {
void *data;
};
+struct dev_multi_pm_domain_data {
+ struct device *dev; /* parent device */
+ struct device **virt_devs; /* virtual children links */
+ struct device_link **links; /* links parent <-> virtual children */
+ int num_domains;
+};
+
#ifdef CONFIG_PM_GENERIC_DOMAINS
static inline struct generic_pm_domain_data *to_gpd_data(struct pm_domain_data *pdd)
{
@@ -369,18 +376,27 @@ 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 dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev);
struct device *dev_pm_domain_attach_by_id(struct device *dev,
unsigned int index);
struct device *dev_pm_domain_attach_by_name(struct device *dev,
const char *name);
void dev_pm_domain_detach(struct device *dev, bool power_off);
int dev_pm_domain_start(struct device *dev);
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd);
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)
{
return 0;
}
+
+struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
+{
+ return NULL;
+}
+
static inline struct device *dev_pm_domain_attach_by_id(struct device *dev,
unsigned int index)
{
@@ -396,6 +412,9 @@ static inline int dev_pm_domain_start(struct device *dev)
{
return 0;
}
+
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd) {}
+
static inline void dev_pm_domain_set(struct device *dev,
struct dev_pm_domain *pd) {}
#endif
--
2.17.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
@ 2020-03-02 20:56 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:56 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: aisheng.dong, daniel.baluta, ulf.hansson, festevam, alsa-devel,
linux-pm, gregkh, s.hauer, khilman, ranjani.sridharan,
linux-kernel, Daniel Baluta, pierre-louis.bossart, paul.olaru,
linux-imx, kernel, shawnguo, shengjiu.wang, linux-arm-kernel
From: Daniel Baluta <daniel.baluta@nxp.com>
This patch introduces helpers support for multi PM domains.
API consists of:
1) dev_multi_pm_attach - powers up all PM domains associated with a given
device. Because we can attach one PM domain per device, we create
virtual devices (children of initial device) and associate PM domains
one per virtual device.
2) dev_multi_pm_detach - detaches all virtual devices from PM domains
attached with.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
drivers/base/power/common.c | 93 +++++++++++++++++++++++++++++++++++++
include/linux/pm_domain.h | 19 ++++++++
2 files changed, 112 insertions(+)
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
index bbddb267c2e6..a90cc6b476e4 100644
--- a/drivers/base/power/common.c
+++ b/drivers/base/power/common.c
@@ -228,3 +228,96 @@ void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd)
device_pm_check_callbacks(dev);
}
EXPORT_SYMBOL_GPL(dev_pm_domain_set);
+
+/**
+ * dev_multi_pm_attach - power up device associated power domains
+ * @dev: The device used to lookup the PM domains
+ *
+ * Parse device's OF node to find all PM domains specifiers. For each power
+ * domain found, create a virtual device and associate it with the
+ * current power domain.
+ *
+ * This function should typically be invoked by a driver during the
+ * probe phase, in the case its device requires power management through
+ * multiple PM domains.
+ *
+ * Returns a pointer to @dev_multi_pm_domain_data if successfully attached PM
+ * domains, NULL if 0 or 1 PM domains specified, else an ERR_PTR() in case of
+ * failures.
+ */
+struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
+{
+ struct dev_multi_pm_domain_data *mpd, *retp;
+ int num_domains;
+ int i;
+
+ num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
+ "#power-domain-cells");
+ if (num_domains < 2)
+ return NULL;
+
+ mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
+ if (!mpd)
+ return ERR_PTR(-ENOMEM);
+
+ mpd->dev = dev;
+ mpd->num_domains = num_domains;
+
+ mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
+ sizeof(*mpd->virt_devs),
+ GFP_KERNEL);
+ if (!mpd->virt_devs)
+ return ERR_PTR(-ENOMEM);
+
+ mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
+ sizeof(*mpd->links), GFP_KERNEL);
+ if (!mpd->links)
+ return ERR_PTR(-ENOMEM);
+
+ for (i = 0; i < mpd->num_domains; i++) {
+ mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
+ if (IS_ERR(mpd->virt_devs[i])) {
+ retp = (struct dev_multi_pm_domain_data *)
+ mpd->virt_devs[i];
+ goto exit_unroll_pm;
+ }
+ mpd->links[i] = device_link_add(dev, mpd->virt_devs[i],
+ DL_FLAG_STATELESS |
+ DL_FLAG_PM_RUNTIME |
+ DL_FLAG_RPM_ACTIVE);
+ if (!mpd->links[i]) {
+ retp = ERR_PTR(-ENOMEM);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ goto exit_unroll_pm;
+ }
+ }
+ return mpd;
+
+exit_unroll_pm:
+ while (--i >= 0) {
+ device_link_del(mpd->links[i]);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ }
+
+ return retp;
+}
+EXPORT_SYMBOL(dev_multi_pm_attach);
+
+/**
+ * dev_multi_pm_detach - Detach a device from its PM domains.
+ * Each multi power domain is attached to a virtual children device
+ *
+ * @mpd: multi power domains data, contains the association between
+ * virtul device and PM domain
+ *
+ */
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd)
+{
+ int i;
+
+ for (i = 0; i < mpd->num_domains; i++) {
+ device_link_del(mpd->links[i]);
+ dev_pm_domain_detach(mpd->virt_devs[i], false);
+ }
+}
+EXPORT_SYMBOL(dev_multi_pm_detach);
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 9ec78ee53652..5bcb35150af2 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -183,6 +183,13 @@ struct generic_pm_domain_data {
void *data;
};
+struct dev_multi_pm_domain_data {
+ struct device *dev; /* parent device */
+ struct device **virt_devs; /* virtual children links */
+ struct device_link **links; /* links parent <-> virtual children */
+ int num_domains;
+};
+
#ifdef CONFIG_PM_GENERIC_DOMAINS
static inline struct generic_pm_domain_data *to_gpd_data(struct pm_domain_data *pdd)
{
@@ -369,18 +376,27 @@ 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 dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev);
struct device *dev_pm_domain_attach_by_id(struct device *dev,
unsigned int index);
struct device *dev_pm_domain_attach_by_name(struct device *dev,
const char *name);
void dev_pm_domain_detach(struct device *dev, bool power_off);
int dev_pm_domain_start(struct device *dev);
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd);
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)
{
return 0;
}
+
+struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
+{
+ return NULL;
+}
+
static inline struct device *dev_pm_domain_attach_by_id(struct device *dev,
unsigned int index)
{
@@ -396,6 +412,9 @@ static inline int dev_pm_domain_start(struct device *dev)
{
return 0;
}
+
+void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd) {}
+
static inline void dev_pm_domain_set(struct device *dev,
struct dev_pm_domain *pd) {}
#endif
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers
2020-03-02 20:56 ` Daniel Baluta
(?)
@ 2020-03-02 20:57 ` Daniel Baluta
-1 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:57 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: gregkh, khilman, ulf.hansson, linux-pm, linux-kernel, shawnguo,
s.hauer, kernel, festevam, linux-imx, daniel.baluta,
pierre-louis.bossart, alsa-devel, linux-arm-kernel, aisheng.dong,
shengjiu.wang, paul.olaru, ranjani.sridharan, Daniel Baluta
From: Daniel Baluta <daniel.baluta@nxp.com>
Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded
version.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
sound/soc/sof/imx/imx8.c | 54 +++++-----------------------------------
1 file changed, 6 insertions(+), 48 deletions(-)
diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
index b692752b2178..ca740538a2d5 100644
--- a/sound/soc/sof/imx/imx8.c
+++ b/sound/soc/sof/imx/imx8.c
@@ -51,10 +51,7 @@ struct imx8_priv {
struct imx_sc_ipc *sc_ipc;
/* Power domain handling */
- int num_domains;
- struct device **pd_dev;
- struct device_link **link;
-
+ struct dev_multi_pm_domain_data *mpd;
};
static void imx8_get_reply(struct snd_sof_dev *sdev)
@@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev)
struct resource res;
u32 base, size;
int ret = 0;
- int i;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
priv->sdev = sdev;
/* power up device associated power domains */
- priv->num_domains = of_count_phandle_with_args(np, "power-domains",
- "#power-domain-cells");
- if (priv->num_domains < 0) {
- dev_err(sdev->dev, "no power-domains property in %pOF\n", np);
- return priv->num_domains;
- }
-
- priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
- sizeof(*priv->pd_dev), GFP_KERNEL);
- if (!priv->pd_dev)
- return -ENOMEM;
-
- priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
- sizeof(*priv->link), GFP_KERNEL);
- if (!priv->link)
- return -ENOMEM;
-
- for (i = 0; i < priv->num_domains; i++) {
- priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i);
- if (IS_ERR(priv->pd_dev[i])) {
- ret = PTR_ERR(priv->pd_dev[i]);
- goto exit_unroll_pm;
- }
- priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i],
- DL_FLAG_STATELESS |
- DL_FLAG_PM_RUNTIME |
- DL_FLAG_RPM_ACTIVE);
- if (!priv->link[i]) {
- ret = -ENOMEM;
- dev_pm_domain_detach(priv->pd_dev[i], false);
- goto exit_unroll_pm;
- }
- }
+ priv->mpd = dev_multi_pm_attach(&pdev->dev);
+ if (IS_ERR(priv->mpd))
+ return PTR_ERR(priv->mpd);
ret = imx_scu_get_handle(&priv->sc_ipc);
if (ret) {
@@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev)
exit_pdev_unregister:
platform_device_unregister(priv->ipc_dev);
exit_unroll_pm:
- while (--i >= 0) {
- device_link_del(priv->link[i]);
- dev_pm_domain_detach(priv->pd_dev[i], false);
- }
-
+ dev_multi_pm_detach(priv->mpd);
return ret;
}
static int imx8_remove(struct snd_sof_dev *sdev)
{
struct imx8_priv *priv = (struct imx8_priv *)sdev->private;
- int i;
platform_device_unregister(priv->ipc_dev);
- for (i = 0; i < priv->num_domains; i++) {
- device_link_del(priv->link[i]);
- dev_pm_domain_detach(priv->pd_dev[i], false);
- }
+ dev_multi_pm_detach(priv->mpd);
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers
@ 2020-03-02 20:57 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:57 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: aisheng.dong, daniel.baluta, ulf.hansson, festevam, alsa-devel,
linux-pm, gregkh, s.hauer, khilman, ranjani.sridharan,
linux-kernel, Daniel Baluta, pierre-louis.bossart, paul.olaru,
linux-imx, kernel, shawnguo, shengjiu.wang, linux-arm-kernel
From: Daniel Baluta <daniel.baluta@nxp.com>
Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded
version.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
sound/soc/sof/imx/imx8.c | 54 +++++-----------------------------------
1 file changed, 6 insertions(+), 48 deletions(-)
diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
index b692752b2178..ca740538a2d5 100644
--- a/sound/soc/sof/imx/imx8.c
+++ b/sound/soc/sof/imx/imx8.c
@@ -51,10 +51,7 @@ struct imx8_priv {
struct imx_sc_ipc *sc_ipc;
/* Power domain handling */
- int num_domains;
- struct device **pd_dev;
- struct device_link **link;
-
+ struct dev_multi_pm_domain_data *mpd;
};
static void imx8_get_reply(struct snd_sof_dev *sdev)
@@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev)
struct resource res;
u32 base, size;
int ret = 0;
- int i;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
priv->sdev = sdev;
/* power up device associated power domains */
- priv->num_domains = of_count_phandle_with_args(np, "power-domains",
- "#power-domain-cells");
- if (priv->num_domains < 0) {
- dev_err(sdev->dev, "no power-domains property in %pOF\n", np);
- return priv->num_domains;
- }
-
- priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
- sizeof(*priv->pd_dev), GFP_KERNEL);
- if (!priv->pd_dev)
- return -ENOMEM;
-
- priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
- sizeof(*priv->link), GFP_KERNEL);
- if (!priv->link)
- return -ENOMEM;
-
- for (i = 0; i < priv->num_domains; i++) {
- priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i);
- if (IS_ERR(priv->pd_dev[i])) {
- ret = PTR_ERR(priv->pd_dev[i]);
- goto exit_unroll_pm;
- }
- priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i],
- DL_FLAG_STATELESS |
- DL_FLAG_PM_RUNTIME |
- DL_FLAG_RPM_ACTIVE);
- if (!priv->link[i]) {
- ret = -ENOMEM;
- dev_pm_domain_detach(priv->pd_dev[i], false);
- goto exit_unroll_pm;
- }
- }
+ priv->mpd = dev_multi_pm_attach(&pdev->dev);
+ if (IS_ERR(priv->mpd))
+ return PTR_ERR(priv->mpd);
ret = imx_scu_get_handle(&priv->sc_ipc);
if (ret) {
@@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev)
exit_pdev_unregister:
platform_device_unregister(priv->ipc_dev);
exit_unroll_pm:
- while (--i >= 0) {
- device_link_del(priv->link[i]);
- dev_pm_domain_detach(priv->pd_dev[i], false);
- }
-
+ dev_multi_pm_detach(priv->mpd);
return ret;
}
static int imx8_remove(struct snd_sof_dev *sdev)
{
struct imx8_priv *priv = (struct imx8_priv *)sdev->private;
- int i;
platform_device_unregister(priv->ipc_dev);
- for (i = 0; i < priv->num_domains; i++) {
- device_link_del(priv->link[i]);
- dev_pm_domain_detach(priv->pd_dev[i], false);
- }
+ dev_multi_pm_detach(priv->mpd);
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers
@ 2020-03-02 20:57 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-02 20:57 UTC (permalink / raw)
To: rjw, len.brown, pavel
Cc: aisheng.dong, daniel.baluta, ulf.hansson, festevam, alsa-devel,
linux-pm, gregkh, s.hauer, khilman, ranjani.sridharan,
linux-kernel, Daniel Baluta, pierre-louis.bossart, paul.olaru,
linux-imx, kernel, shawnguo, shengjiu.wang, linux-arm-kernel
From: Daniel Baluta <daniel.baluta@nxp.com>
Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded
version.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
sound/soc/sof/imx/imx8.c | 54 +++++-----------------------------------
1 file changed, 6 insertions(+), 48 deletions(-)
diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
index b692752b2178..ca740538a2d5 100644
--- a/sound/soc/sof/imx/imx8.c
+++ b/sound/soc/sof/imx/imx8.c
@@ -51,10 +51,7 @@ struct imx8_priv {
struct imx_sc_ipc *sc_ipc;
/* Power domain handling */
- int num_domains;
- struct device **pd_dev;
- struct device_link **link;
-
+ struct dev_multi_pm_domain_data *mpd;
};
static void imx8_get_reply(struct snd_sof_dev *sdev)
@@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev)
struct resource res;
u32 base, size;
int ret = 0;
- int i;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
priv->sdev = sdev;
/* power up device associated power domains */
- priv->num_domains = of_count_phandle_with_args(np, "power-domains",
- "#power-domain-cells");
- if (priv->num_domains < 0) {
- dev_err(sdev->dev, "no power-domains property in %pOF\n", np);
- return priv->num_domains;
- }
-
- priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
- sizeof(*priv->pd_dev), GFP_KERNEL);
- if (!priv->pd_dev)
- return -ENOMEM;
-
- priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
- sizeof(*priv->link), GFP_KERNEL);
- if (!priv->link)
- return -ENOMEM;
-
- for (i = 0; i < priv->num_domains; i++) {
- priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i);
- if (IS_ERR(priv->pd_dev[i])) {
- ret = PTR_ERR(priv->pd_dev[i]);
- goto exit_unroll_pm;
- }
- priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i],
- DL_FLAG_STATELESS |
- DL_FLAG_PM_RUNTIME |
- DL_FLAG_RPM_ACTIVE);
- if (!priv->link[i]) {
- ret = -ENOMEM;
- dev_pm_domain_detach(priv->pd_dev[i], false);
- goto exit_unroll_pm;
- }
- }
+ priv->mpd = dev_multi_pm_attach(&pdev->dev);
+ if (IS_ERR(priv->mpd))
+ return PTR_ERR(priv->mpd);
ret = imx_scu_get_handle(&priv->sc_ipc);
if (ret) {
@@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev)
exit_pdev_unregister:
platform_device_unregister(priv->ipc_dev);
exit_unroll_pm:
- while (--i >= 0) {
- device_link_del(priv->link[i]);
- dev_pm_domain_detach(priv->pd_dev[i], false);
- }
-
+ dev_multi_pm_detach(priv->mpd);
return ret;
}
static int imx8_remove(struct snd_sof_dev *sdev)
{
struct imx8_priv *priv = (struct imx8_priv *)sdev->private;
- int i;
platform_device_unregister(priv->ipc_dev);
- for (i = 0; i < priv->num_domains; i++) {
- device_link_del(priv->link[i]);
- dev_pm_domain_detach(priv->pd_dev[i], false);
- }
+ dev_multi_pm_detach(priv->mpd);
return 0;
}
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
2020-03-02 20:56 ` Daniel Baluta
(?)
(?)
@ 2020-03-02 21:23 ` Sridharan, Ranjani
2020-03-03 13:29 ` Daniel Baluta
-1 siblings, 1 reply; 20+ messages in thread
From: Sridharan, Ranjani @ 2020-03-02 21:23 UTC (permalink / raw)
To: Daniel Baluta
Cc: Linux-ALSA, ulf.hansson, Pierre-Louis Bossart, pavel, festevam,
khilman, Ranjani Sridharan, linux-imx, Brown, Len, linux-pm,
s.hauer, paul.olaru, Daniel Baluta, linux-arm-kernel,
aisheng.dong, Daniel Baluta, Greg KH, shengjiu.wang, rjw,
linux-kernel, kernel, shawnguo
On Mon, Mar 2, 2020 at 12:59 PM Daniel Baluta <daniel.baluta@oss.nxp.com>
wrote:
> From: Daniel Baluta <daniel.baluta@nxp.com>
>
> This patch introduces helpers support for multi PM domains.
>
> API consists of:
>
> 1) dev_multi_pm_attach - powers up all PM domains associated with a given
> device. Because we can attach one PM domain per device, we create
> virtual devices (children of initial device) and associate PM domains
> one per virtual device.
>
> 2) dev_multi_pm_detach - detaches all virtual devices from PM domains
> attached with.
>
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
> drivers/base/power/common.c | 93 +++++++++++++++++++++++++++++++++++++
> include/linux/pm_domain.h | 19 ++++++++
> 2 files changed, 112 insertions(+)
>
> diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
> index bbddb267c2e6..a90cc6b476e4 100644
> --- a/drivers/base/power/common.c
> +++ b/drivers/base/power/common.c
> @@ -228,3 +228,96 @@ void dev_pm_domain_set(struct device *dev, struct
> dev_pm_domain *pd)
> device_pm_check_callbacks(dev);
> }
> EXPORT_SYMBOL_GPL(dev_pm_domain_set);
> +
> +/**
> + * dev_multi_pm_attach - power up device associated power domains
> + * @dev: The device used to lookup the PM domains
> + *
> + * Parse device's OF node to find all PM domains specifiers. For each
> power
> + * domain found, create a virtual device and associate it with the
> + * current power domain.
> + *
> + * This function should typically be invoked by a driver during the
> + * probe phase, in the case its device requires power management through
> + * multiple PM domains.
> + *
> + * Returns a pointer to @dev_multi_pm_domain_data if successfully
> attached PM
> + * domains, NULL if 0 or 1 PM domains specified, else an ERR_PTR() in
> case of
> + * failures.
> + */
> +struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
> +{
> + struct dev_multi_pm_domain_data *mpd, *retp;
> + int num_domains;
> + int i;
> +
> + num_domains = of_count_phandle_with_args(dev->of_node,
> "power-domains",
> + "#power-domain-cells");
> + if (num_domains < 2)
>
Hi Daniel,
Just out of curiosity, should it be an error when num_domains is 1? Is it
an error because the expectation is that the caller would use
dev_pm_domain_attach() in that case?
+ return NULL;
> +
> + mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
> + if (!mpd)
> + return ERR_PTR(-ENOMEM);
> +
> + mpd->dev = dev;
> + mpd->num_domains = num_domains;
> +
> + mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
> + sizeof(*mpd->virt_devs),
> + GFP_KERNEL);
> + if (!mpd->virt_devs)
> + return ERR_PTR(-ENOMEM);
> +
> + mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
> + sizeof(*mpd->links), GFP_KERNEL);
> + if (!mpd->links)
> + return ERR_PTR(-ENOMEM);
> +
> + for (i = 0; i < mpd->num_domains; i++) {
> + mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
> + if (IS_ERR(mpd->virt_devs[i])) {
> + retp = (struct dev_multi_pm_domain_data *)
> + mpd->virt_devs[i];
>
Should retp be PTR_ERR(mpd->virt_devs[i]) here?
Thanks,
Ranjani
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers
2020-03-02 20:57 ` Daniel Baluta
(?)
(?)
@ 2020-03-02 21:26 ` Sridharan, Ranjani
2020-03-03 13:17 ` Daniel Baluta
-1 siblings, 1 reply; 20+ messages in thread
From: Sridharan, Ranjani @ 2020-03-02 21:26 UTC (permalink / raw)
To: Daniel Baluta
Cc: Linux-ALSA, ulf.hansson, Pierre-Louis Bossart, pavel, festevam,
khilman, Ranjani Sridharan, linux-imx, Brown, Len, linux-pm,
s.hauer, paul.olaru, Daniel Baluta, linux-arm-kernel,
aisheng.dong, Daniel Baluta, Greg KH, shengjiu.wang, rjw,
linux-kernel, kernel, shawnguo
On Mon, Mar 2, 2020 at 1:00 PM Daniel Baluta <daniel.baluta@oss.nxp.com>
wrote:
> From: Daniel Baluta <daniel.baluta@nxp.com>
>
> Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded
> version.
>
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
> sound/soc/sof/imx/imx8.c | 54 +++++-----------------------------------
> 1 file changed, 6 insertions(+), 48 deletions(-)
>
> diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
> index b692752b2178..ca740538a2d5 100644
> --- a/sound/soc/sof/imx/imx8.c
> +++ b/sound/soc/sof/imx/imx8.c
> @@ -51,10 +51,7 @@ struct imx8_priv {
> struct imx_sc_ipc *sc_ipc;
>
> /* Power domain handling */
> - int num_domains;
> - struct device **pd_dev;
> - struct device_link **link;
> -
> + struct dev_multi_pm_domain_data *mpd;
> };
>
> static void imx8_get_reply(struct snd_sof_dev *sdev)
> @@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev)
> struct resource res;
> u32 base, size;
> int ret = 0;
> - int i;
>
> priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> @@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
> priv->sdev = sdev;
>
> /* power up device associated power domains */
> - priv->num_domains = of_count_phandle_with_args(np, "power-domains",
> -
> "#power-domain-cells");
> - if (priv->num_domains < 0) {
> - dev_err(sdev->dev, "no power-domains property in %pOF\n",
> np);
> - return priv->num_domains;
> - }
> -
> - priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
> - sizeof(*priv->pd_dev),
> GFP_KERNEL);
> - if (!priv->pd_dev)
> - return -ENOMEM;
> -
> - priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
> - sizeof(*priv->link), GFP_KERNEL);
> - if (!priv->link)
> - return -ENOMEM;
> -
> - for (i = 0; i < priv->num_domains; i++) {
> - priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev,
> i);
> - if (IS_ERR(priv->pd_dev[i])) {
> - ret = PTR_ERR(priv->pd_dev[i]);
> - goto exit_unroll_pm;
> - }
> - priv->link[i] = device_link_add(&pdev->dev,
> priv->pd_dev[i],
> - DL_FLAG_STATELESS |
> - DL_FLAG_PM_RUNTIME |
> - DL_FLAG_RPM_ACTIVE);
> - if (!priv->link[i]) {
> - ret = -ENOMEM;
> - dev_pm_domain_detach(priv->pd_dev[i], false);
> - goto exit_unroll_pm;
> - }
> - }
> + priv->mpd = dev_multi_pm_attach(&pdev->dev);
> + if (IS_ERR(priv->mpd))
> + return PTR_ERR(priv->mpd);
>
> ret = imx_scu_get_handle(&priv->sc_ipc);
> if (ret) {
> @@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev)
> exit_pdev_unregister:
> platform_device_unregister(priv->ipc_dev);
> exit_unroll_pm:
>
Can we also rename the label to exit_pm_detach maybe? It is no longer an
unroll anymore right?
Thanks,
Ranjani
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
2020-03-02 20:56 ` Daniel Baluta
` (2 preceding siblings ...)
(?)
@ 2020-03-03 5:36 ` kbuild test robot
-1 siblings, 0 replies; 20+ messages in thread
From: kbuild test robot @ 2020-03-03 5:36 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 1734 bytes --]
Hi Daniel,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on pm/linux-next]
[also build test ERROR on shawnguo/for-next pavel-linux-leds/for-next v5.6-rc4 next-20200302]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-Baluta/Introduce-multi-PM-domains-helpers/20200303-050542
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: nds32-allnoconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=nds32
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
nds32le-linux-ld: drivers/base/power/clock_ops.o: in function `dev_multi_pm_attach':
>> clock_ops.c:(.text+0x124): multiple definition of `dev_multi_pm_attach'; drivers/base/platform.o:platform.c:(.text+0x3c4): first defined here
nds32le-linux-ld: drivers/base/power/clock_ops.o: in function `dev_multi_pm_detach':
>> clock_ops.c:(.text+0x128): multiple definition of `dev_multi_pm_detach'; drivers/base/platform.o:platform.c:(.text+0x3c8): first defined here
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 5253 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
2020-03-02 20:56 ` Daniel Baluta
` (3 preceding siblings ...)
(?)
@ 2020-03-03 6:08 ` kbuild test robot
-1 siblings, 0 replies; 20+ messages in thread
From: kbuild test robot @ 2020-03-03 6:08 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 4372 bytes --]
Hi Daniel,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on pm/linux-next]
[also build test WARNING on shawnguo/for-next pavel-linux-leds/for-next v5.6-rc4 next-20200302]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-Baluta/Introduce-multi-PM-domains-helpers/20200303-050542
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-174-g094d5a94-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/base/power/common.c:259:33: sparse: sparse: incorrect type in argument 2 (different base types)
>> drivers/base/power/common.c:259:33: sparse: expected unsigned int [usertype] size
>> drivers/base/power/common.c:259:33: sparse: got restricted gfp_t
drivers/base/power/common.c:259:45: sparse: sparse: incorrect type in argument 3 (different base types)
>> drivers/base/power/common.c:259:45: sparse: expected restricted gfp_t [usertype] gfp
>> drivers/base/power/common.c:259:45: sparse: got unsigned int
vim +259 drivers/base/power/common.c
231
232 /**
233 * dev_multi_pm_attach - power up device associated power domains
234 * @dev: The device used to lookup the PM domains
235 *
236 * Parse device's OF node to find all PM domains specifiers. For each power
237 * domain found, create a virtual device and associate it with the
238 * current power domain.
239 *
240 * This function should typically be invoked by a driver during the
241 * probe phase, in the case its device requires power management through
242 * multiple PM domains.
243 *
244 * Returns a pointer to @dev_multi_pm_domain_data if successfully attached PM
245 * domains, NULL if 0 or 1 PM domains specified, else an ERR_PTR() in case of
246 * failures.
247 */
248 struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
249 {
250 struct dev_multi_pm_domain_data *mpd, *retp;
251 int num_domains;
252 int i;
253
254 num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
255 "#power-domain-cells");
256 if (num_domains < 2)
257 return NULL;
258
> 259 mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
260 if (!mpd)
261 return ERR_PTR(-ENOMEM);
262
263 mpd->dev = dev;
264 mpd->num_domains = num_domains;
265
266 mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
267 sizeof(*mpd->virt_devs),
268 GFP_KERNEL);
269 if (!mpd->virt_devs)
270 return ERR_PTR(-ENOMEM);
271
272 mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
273 sizeof(*mpd->links), GFP_KERNEL);
274 if (!mpd->links)
275 return ERR_PTR(-ENOMEM);
276
277 for (i = 0; i < mpd->num_domains; i++) {
278 mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
279 if (IS_ERR(mpd->virt_devs[i])) {
280 retp = (struct dev_multi_pm_domain_data *)
281 mpd->virt_devs[i];
282 goto exit_unroll_pm;
283 }
284 mpd->links[i] = device_link_add(dev, mpd->virt_devs[i],
285 DL_FLAG_STATELESS |
286 DL_FLAG_PM_RUNTIME |
287 DL_FLAG_RPM_ACTIVE);
288 if (!mpd->links[i]) {
289 retp = ERR_PTR(-ENOMEM);
290 dev_pm_domain_detach(mpd->virt_devs[i], false);
291 goto exit_unroll_pm;
292 }
293 }
294 return mpd;
295
296 exit_unroll_pm:
297 while (--i >= 0) {
298 device_link_del(mpd->links[i]);
299 dev_pm_domain_detach(mpd->virt_devs[i], false);
300 }
301
302 return retp;
303 }
304 EXPORT_SYMBOL(dev_multi_pm_attach);
305
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
2020-03-02 20:56 ` Daniel Baluta
` (4 preceding siblings ...)
(?)
@ 2020-03-03 8:14 ` kbuild test robot
-1 siblings, 0 replies; 20+ messages in thread
From: kbuild test robot @ 2020-03-03 8:14 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 2981 bytes --]
Hi Daniel,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on pm/linux-next]
[also build test ERROR on shawnguo/for-next pavel-linux-leds/for-next v5.6-rc4 next-20200302]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-Baluta/Introduce-multi-PM-domains-helpers/20200303-050542
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: openrisc-randconfig-a001-20200302 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=openrisc
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
or1k-linux-ld: drivers/opp/core.o: in function `dev_multi_pm_attach':
>> include/linux/pm_domain.h:396: multiple definition of `dev_multi_pm_attach'; drivers/base/platform.o:include/linux/pm_domain.h:396: first defined here
or1k-linux-ld: drivers/opp/core.o: in function `dev_multi_pm_detach':
>> include/linux/pm_domain.h:416: multiple definition of `dev_multi_pm_detach'; drivers/base/platform.o:include/linux/pm_domain.h:416: first defined here
or1k-linux-ld: drivers/opp/of.o: in function `dev_multi_pm_attach':
>> include/linux/pm_domain.h:396: multiple definition of `dev_multi_pm_attach'; drivers/base/platform.o:include/linux/pm_domain.h:396: first defined here
or1k-linux-ld: drivers/opp/of.o: in function `dev_multi_pm_detach':
>> include/linux/pm_domain.h:416: multiple definition of `dev_multi_pm_detach'; drivers/base/platform.o:include/linux/pm_domain.h:416: first defined here
vim +396 include/linux/pm_domain.h
394
395 struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
> 396 {
397 return NULL;
398 }
399
400 static inline struct device *dev_pm_domain_attach_by_id(struct device *dev,
401 unsigned int index)
402 {
403 return NULL;
404 }
405 static inline struct device *dev_pm_domain_attach_by_name(struct device *dev,
406 const char *name)
407 {
408 return NULL;
409 }
410 static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {}
411 static inline int dev_pm_domain_start(struct device *dev)
412 {
413 return 0;
414 }
415
> 416 void dev_multi_pm_detach(struct dev_multi_pm_domain_data *mpd) {}
417
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 26498 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers
2020-03-02 21:26 ` Sridharan, Ranjani
2020-03-03 13:17 ` Daniel Baluta
@ 2020-03-03 13:17 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-03 13:17 UTC (permalink / raw)
To: Sridharan, Ranjani
Cc: Daniel Baluta, rjw, Brown, Len, Pavel Machek, Aisheng Dong,
Ulf Hansson, Fabio Estevam, Linux-ALSA, linux-pm, Greg KH,
Sascha Hauer, khilman, Ranjani Sridharan,
Linux Kernel Mailing List, Daniel Baluta, Pierre-Louis Bossart,
Paul Olaru, dl-linux-imx, Pengutronix Kernel Team, Shawn Guo,
S.j. Wang, linux-arm-kernel
On Mon, Mar 2, 2020 at 11:26 PM Sridharan, Ranjani
<ranjani.sridharan@intel.com> wrote:
>
>
>
> On Mon, Mar 2, 2020 at 1:00 PM Daniel Baluta <daniel.baluta@oss.nxp.com> wrote:
>>
>> From: Daniel Baluta <daniel.baluta@nxp.com>
>>
>> Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded
>> version.
>>
>> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
>> ---
>> sound/soc/sof/imx/imx8.c | 54 +++++-----------------------------------
>> 1 file changed, 6 insertions(+), 48 deletions(-)
>>
>> diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
>> index b692752b2178..ca740538a2d5 100644
>> --- a/sound/soc/sof/imx/imx8.c
>> +++ b/sound/soc/sof/imx/imx8.c
>> @@ -51,10 +51,7 @@ struct imx8_priv {
>> struct imx_sc_ipc *sc_ipc;
>>
>> /* Power domain handling */
>> - int num_domains;
>> - struct device **pd_dev;
>> - struct device_link **link;
>> -
>> + struct dev_multi_pm_domain_data *mpd;
>> };
>>
>> static void imx8_get_reply(struct snd_sof_dev *sdev)
>> @@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> struct resource res;
>> u32 base, size;
>> int ret = 0;
>> - int i;
>>
>> priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
>> if (!priv)
>> @@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> priv->sdev = sdev;
>>
>> /* power up device associated power domains */
>> - priv->num_domains = of_count_phandle_with_args(np, "power-domains",
>> - "#power-domain-cells");
>> - if (priv->num_domains < 0) {
>> - dev_err(sdev->dev, "no power-domains property in %pOF\n", np);
>> - return priv->num_domains;
>> - }
>> -
>> - priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
>> - sizeof(*priv->pd_dev), GFP_KERNEL);
>> - if (!priv->pd_dev)
>> - return -ENOMEM;
>> -
>> - priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
>> - sizeof(*priv->link), GFP_KERNEL);
>> - if (!priv->link)
>> - return -ENOMEM;
>> -
>> - for (i = 0; i < priv->num_domains; i++) {
>> - priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i);
>> - if (IS_ERR(priv->pd_dev[i])) {
>> - ret = PTR_ERR(priv->pd_dev[i]);
>> - goto exit_unroll_pm;
>> - }
>> - priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i],
>> - DL_FLAG_STATELESS |
>> - DL_FLAG_PM_RUNTIME |
>> - DL_FLAG_RPM_ACTIVE);
>> - if (!priv->link[i]) {
>> - ret = -ENOMEM;
>> - dev_pm_domain_detach(priv->pd_dev[i], false);
>> - goto exit_unroll_pm;
>> - }
>> - }
>> + priv->mpd = dev_multi_pm_attach(&pdev->dev);
>> + if (IS_ERR(priv->mpd))
>> + return PTR_ERR(priv->mpd);
>>
>> ret = imx_scu_get_handle(&priv->sc_ipc);
>> if (ret) {
>> @@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> exit_pdev_unregister:
>> platform_device_unregister(priv->ipc_dev);
>> exit_unroll_pm:
>
> Can we also rename the label to exit_pm_detach maybe? It is no longer an unroll anymore right?
Sure, will do in v2.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers
@ 2020-03-03 13:17 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-03 13:17 UTC (permalink / raw)
To: Sridharan, Ranjani
Cc: Ulf Hansson, Daniel Baluta, Linux-ALSA, Pierre-Louis Bossart,
Pavel Machek, Fabio Estevam, khilman, Ranjani Sridharan,
dl-linux-imx, Brown, Len, linux-pm, Sascha Hauer, Paul Olaru,
Daniel Baluta, linux-arm-kernel, Aisheng Dong, Greg KH,
S.j. Wang, rjw, Linux Kernel Mailing List,
Pengutronix Kernel Team, Shawn Guo
On Mon, Mar 2, 2020 at 11:26 PM Sridharan, Ranjani
<ranjani.sridharan@intel.com> wrote:
>
>
>
> On Mon, Mar 2, 2020 at 1:00 PM Daniel Baluta <daniel.baluta@oss.nxp.com> wrote:
>>
>> From: Daniel Baluta <daniel.baluta@nxp.com>
>>
>> Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded
>> version.
>>
>> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
>> ---
>> sound/soc/sof/imx/imx8.c | 54 +++++-----------------------------------
>> 1 file changed, 6 insertions(+), 48 deletions(-)
>>
>> diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
>> index b692752b2178..ca740538a2d5 100644
>> --- a/sound/soc/sof/imx/imx8.c
>> +++ b/sound/soc/sof/imx/imx8.c
>> @@ -51,10 +51,7 @@ struct imx8_priv {
>> struct imx_sc_ipc *sc_ipc;
>>
>> /* Power domain handling */
>> - int num_domains;
>> - struct device **pd_dev;
>> - struct device_link **link;
>> -
>> + struct dev_multi_pm_domain_data *mpd;
>> };
>>
>> static void imx8_get_reply(struct snd_sof_dev *sdev)
>> @@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> struct resource res;
>> u32 base, size;
>> int ret = 0;
>> - int i;
>>
>> priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
>> if (!priv)
>> @@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> priv->sdev = sdev;
>>
>> /* power up device associated power domains */
>> - priv->num_domains = of_count_phandle_with_args(np, "power-domains",
>> - "#power-domain-cells");
>> - if (priv->num_domains < 0) {
>> - dev_err(sdev->dev, "no power-domains property in %pOF\n", np);
>> - return priv->num_domains;
>> - }
>> -
>> - priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
>> - sizeof(*priv->pd_dev), GFP_KERNEL);
>> - if (!priv->pd_dev)
>> - return -ENOMEM;
>> -
>> - priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
>> - sizeof(*priv->link), GFP_KERNEL);
>> - if (!priv->link)
>> - return -ENOMEM;
>> -
>> - for (i = 0; i < priv->num_domains; i++) {
>> - priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i);
>> - if (IS_ERR(priv->pd_dev[i])) {
>> - ret = PTR_ERR(priv->pd_dev[i]);
>> - goto exit_unroll_pm;
>> - }
>> - priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i],
>> - DL_FLAG_STATELESS |
>> - DL_FLAG_PM_RUNTIME |
>> - DL_FLAG_RPM_ACTIVE);
>> - if (!priv->link[i]) {
>> - ret = -ENOMEM;
>> - dev_pm_domain_detach(priv->pd_dev[i], false);
>> - goto exit_unroll_pm;
>> - }
>> - }
>> + priv->mpd = dev_multi_pm_attach(&pdev->dev);
>> + if (IS_ERR(priv->mpd))
>> + return PTR_ERR(priv->mpd);
>>
>> ret = imx_scu_get_handle(&priv->sc_ipc);
>> if (ret) {
>> @@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> exit_pdev_unregister:
>> platform_device_unregister(priv->ipc_dev);
>> exit_unroll_pm:
>
> Can we also rename the label to exit_pm_detach maybe? It is no longer an unroll anymore right?
Sure, will do in v2.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers
@ 2020-03-03 13:17 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-03 13:17 UTC (permalink / raw)
To: Sridharan, Ranjani
Cc: Ulf Hansson, Daniel Baluta, Linux-ALSA, Pierre-Louis Bossart,
Pavel Machek, Fabio Estevam, khilman, Ranjani Sridharan,
dl-linux-imx, Brown, Len, linux-pm, Sascha Hauer, Paul Olaru,
Daniel Baluta, linux-arm-kernel, Aisheng Dong, Greg KH,
S.j. Wang, rjw, Linux Kernel Mailing List,
Pengutronix Kernel Team, Shawn Guo
On Mon, Mar 2, 2020 at 11:26 PM Sridharan, Ranjani
<ranjani.sridharan@intel.com> wrote:
>
>
>
> On Mon, Mar 2, 2020 at 1:00 PM Daniel Baluta <daniel.baluta@oss.nxp.com> wrote:
>>
>> From: Daniel Baluta <daniel.baluta@nxp.com>
>>
>> Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded
>> version.
>>
>> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
>> ---
>> sound/soc/sof/imx/imx8.c | 54 +++++-----------------------------------
>> 1 file changed, 6 insertions(+), 48 deletions(-)
>>
>> diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
>> index b692752b2178..ca740538a2d5 100644
>> --- a/sound/soc/sof/imx/imx8.c
>> +++ b/sound/soc/sof/imx/imx8.c
>> @@ -51,10 +51,7 @@ struct imx8_priv {
>> struct imx_sc_ipc *sc_ipc;
>>
>> /* Power domain handling */
>> - int num_domains;
>> - struct device **pd_dev;
>> - struct device_link **link;
>> -
>> + struct dev_multi_pm_domain_data *mpd;
>> };
>>
>> static void imx8_get_reply(struct snd_sof_dev *sdev)
>> @@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> struct resource res;
>> u32 base, size;
>> int ret = 0;
>> - int i;
>>
>> priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
>> if (!priv)
>> @@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> priv->sdev = sdev;
>>
>> /* power up device associated power domains */
>> - priv->num_domains = of_count_phandle_with_args(np, "power-domains",
>> - "#power-domain-cells");
>> - if (priv->num_domains < 0) {
>> - dev_err(sdev->dev, "no power-domains property in %pOF\n", np);
>> - return priv->num_domains;
>> - }
>> -
>> - priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
>> - sizeof(*priv->pd_dev), GFP_KERNEL);
>> - if (!priv->pd_dev)
>> - return -ENOMEM;
>> -
>> - priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
>> - sizeof(*priv->link), GFP_KERNEL);
>> - if (!priv->link)
>> - return -ENOMEM;
>> -
>> - for (i = 0; i < priv->num_domains; i++) {
>> - priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i);
>> - if (IS_ERR(priv->pd_dev[i])) {
>> - ret = PTR_ERR(priv->pd_dev[i]);
>> - goto exit_unroll_pm;
>> - }
>> - priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i],
>> - DL_FLAG_STATELESS |
>> - DL_FLAG_PM_RUNTIME |
>> - DL_FLAG_RPM_ACTIVE);
>> - if (!priv->link[i]) {
>> - ret = -ENOMEM;
>> - dev_pm_domain_detach(priv->pd_dev[i], false);
>> - goto exit_unroll_pm;
>> - }
>> - }
>> + priv->mpd = dev_multi_pm_attach(&pdev->dev);
>> + if (IS_ERR(priv->mpd))
>> + return PTR_ERR(priv->mpd);
>>
>> ret = imx_scu_get_handle(&priv->sc_ipc);
>> if (ret) {
>> @@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev)
>> exit_pdev_unregister:
>> platform_device_unregister(priv->ipc_dev);
>> exit_unroll_pm:
>
> Can we also rename the label to exit_pm_detach maybe? It is no longer an unroll anymore right?
Sure, will do in v2.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
2020-03-02 21:23 ` Sridharan, Ranjani
2020-03-03 13:29 ` Daniel Baluta
@ 2020-03-03 13:29 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-03 13:29 UTC (permalink / raw)
To: Sridharan, Ranjani
Cc: Daniel Baluta, rjw, Brown, Len, Pavel Machek, Aisheng Dong,
Ulf Hansson, Fabio Estevam, Linux-ALSA, linux-pm, Greg KH,
Sascha Hauer, khilman, Ranjani Sridharan,
Linux Kernel Mailing List, Daniel Baluta, Pierre-Louis Bossart,
Paul Olaru, dl-linux-imx, Pengutronix Kernel Team, Shawn Guo,
S.j. Wang, linux-arm-kernel
Hello Ranjani,
On Mon, Mar 2, 2020 at 11:24 PM Sridharan, Ranjani
<ranjani.sridharan@intel.com> wrote:
>> + */
>> +struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
>> +{
>> + struct dev_multi_pm_domain_data *mpd, *retp;
>> + int num_domains;
>> + int i;
>> +
>> + num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
>> + "#power-domain-cells");
>> + if (num_domains < 2)
>
> Hi Daniel,
>
> Just out of curiosity, should it be an error when num_domains is 1? Is it an error because the expectation is that the caller would use dev_pm_domain_attach() in that case?
NULL here doesn't really mean an error. It means that we don't need to
handle Power domains because as you said the caller
already used dev_pm_domain_attach.
Similar with this:
$ drivers/base/power/domain.c +2504
int genpd_dev_pm_attach(struct device *dev)
/ * 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;
Will update the description for when this function returns a NULL.
>
>> + return NULL;
>> +
>> + mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
>> + if (!mpd)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + mpd->dev = dev;
>> + mpd->num_domains = num_domains;
>> +
>> + mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
>> + sizeof(*mpd->virt_devs),
>> + GFP_KERNEL);
>> + if (!mpd->virt_devs)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
>> + sizeof(*mpd->links), GFP_KERNEL);
>> + if (!mpd->links)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + for (i = 0; i < mpd->num_domains; i++) {
>> + mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
>> + if (IS_ERR(mpd->virt_devs[i])) {
>> + retp = (struct dev_multi_pm_domain_data *)
>> + mpd->virt_devs[i];
>
> Should retp be PTR_ERR(mpd->virt_devs[i]) here?
PTR_ERR returns a long but our function needs to return struct
dev_multi_pm_domain_data *.
> Thanks,
> Ranjani
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
@ 2020-03-03 13:29 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-03 13:29 UTC (permalink / raw)
To: Sridharan, Ranjani
Cc: Ulf Hansson, Daniel Baluta, Linux-ALSA, Pierre-Louis Bossart,
Pavel Machek, Fabio Estevam, khilman, Ranjani Sridharan,
dl-linux-imx, Brown, Len, linux-pm, Sascha Hauer, Paul Olaru,
Daniel Baluta, linux-arm-kernel, Aisheng Dong, Greg KH,
S.j. Wang, rjw, Linux Kernel Mailing List,
Pengutronix Kernel Team, Shawn Guo
Hello Ranjani,
On Mon, Mar 2, 2020 at 11:24 PM Sridharan, Ranjani
<ranjani.sridharan@intel.com> wrote:
>> + */
>> +struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
>> +{
>> + struct dev_multi_pm_domain_data *mpd, *retp;
>> + int num_domains;
>> + int i;
>> +
>> + num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
>> + "#power-domain-cells");
>> + if (num_domains < 2)
>
> Hi Daniel,
>
> Just out of curiosity, should it be an error when num_domains is 1? Is it an error because the expectation is that the caller would use dev_pm_domain_attach() in that case?
NULL here doesn't really mean an error. It means that we don't need to
handle Power domains because as you said the caller
already used dev_pm_domain_attach.
Similar with this:
$ drivers/base/power/domain.c +2504
int genpd_dev_pm_attach(struct device *dev)
/ * 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;
Will update the description for when this function returns a NULL.
>
>> + return NULL;
>> +
>> + mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
>> + if (!mpd)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + mpd->dev = dev;
>> + mpd->num_domains = num_domains;
>> +
>> + mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
>> + sizeof(*mpd->virt_devs),
>> + GFP_KERNEL);
>> + if (!mpd->virt_devs)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
>> + sizeof(*mpd->links), GFP_KERNEL);
>> + if (!mpd->links)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + for (i = 0; i < mpd->num_domains; i++) {
>> + mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
>> + if (IS_ERR(mpd->virt_devs[i])) {
>> + retp = (struct dev_multi_pm_domain_data *)
>> + mpd->virt_devs[i];
>
> Should retp be PTR_ERR(mpd->virt_devs[i]) here?
PTR_ERR returns a long but our function needs to return struct
dev_multi_pm_domain_data *.
> Thanks,
> Ranjani
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
@ 2020-03-03 13:29 ` Daniel Baluta
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Baluta @ 2020-03-03 13:29 UTC (permalink / raw)
To: Sridharan, Ranjani
Cc: Ulf Hansson, Daniel Baluta, Linux-ALSA, Pierre-Louis Bossart,
Pavel Machek, Fabio Estevam, khilman, Ranjani Sridharan,
dl-linux-imx, Brown, Len, linux-pm, Sascha Hauer, Paul Olaru,
Daniel Baluta, linux-arm-kernel, Aisheng Dong, Greg KH,
S.j. Wang, rjw, Linux Kernel Mailing List,
Pengutronix Kernel Team, Shawn Guo
Hello Ranjani,
On Mon, Mar 2, 2020 at 11:24 PM Sridharan, Ranjani
<ranjani.sridharan@intel.com> wrote:
>> + */
>> +struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
>> +{
>> + struct dev_multi_pm_domain_data *mpd, *retp;
>> + int num_domains;
>> + int i;
>> +
>> + num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
>> + "#power-domain-cells");
>> + if (num_domains < 2)
>
> Hi Daniel,
>
> Just out of curiosity, should it be an error when num_domains is 1? Is it an error because the expectation is that the caller would use dev_pm_domain_attach() in that case?
NULL here doesn't really mean an error. It means that we don't need to
handle Power domains because as you said the caller
already used dev_pm_domain_attach.
Similar with this:
$ drivers/base/power/domain.c +2504
int genpd_dev_pm_attach(struct device *dev)
/ * 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;
Will update the description for when this function returns a NULL.
>
>> + return NULL;
>> +
>> + mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
>> + if (!mpd)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + mpd->dev = dev;
>> + mpd->num_domains = num_domains;
>> +
>> + mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
>> + sizeof(*mpd->virt_devs),
>> + GFP_KERNEL);
>> + if (!mpd->virt_devs)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
>> + sizeof(*mpd->links), GFP_KERNEL);
>> + if (!mpd->links)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + for (i = 0; i < mpd->num_domains; i++) {
>> + mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
>> + if (IS_ERR(mpd->virt_devs[i])) {
>> + retp = (struct dev_multi_pm_domain_data *)
>> + mpd->virt_devs[i];
>
> Should retp be PTR_ERR(mpd->virt_devs[i]) here?
PTR_ERR returns a long but our function needs to return struct
dev_multi_pm_domain_data *.
> Thanks,
> Ranjani
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2020-03-03 13:30 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02 20:56 [RFC PATCH 0/2] Introduce multi PM domains helpers Daniel Baluta
2020-03-02 20:56 ` Daniel Baluta
2020-03-02 20:56 ` Daniel Baluta
2020-03-02 20:56 ` [RFC PATCH 1/2] PM / domains: " Daniel Baluta
2020-03-02 20:56 ` Daniel Baluta
2020-03-02 20:56 ` Daniel Baluta
2020-03-02 21:23 ` Sridharan, Ranjani
2020-03-03 13:29 ` Daniel Baluta
2020-03-03 13:29 ` Daniel Baluta
2020-03-03 13:29 ` Daniel Baluta
2020-03-03 5:36 ` kbuild test robot
2020-03-03 6:08 ` kbuild test robot
2020-03-03 8:14 ` kbuild test robot
2020-03-02 20:57 ` [RFC PATCH 2/2] ASoC: SOF: Use " Daniel Baluta
2020-03-02 20:57 ` Daniel Baluta
2020-03-02 20:57 ` Daniel Baluta
2020-03-02 21:26 ` Sridharan, Ranjani
2020-03-03 13:17 ` Daniel Baluta
2020-03-03 13:17 ` Daniel Baluta
2020-03-03 13:17 ` Daniel Baluta
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.