All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM / Domains: Allow holes in genpd_data.domains array
@ 2016-09-15 10:39 Tomeu Vizoso
  2016-09-15 11:03   ` Jon Hunter
  0 siblings, 1 reply; 9+ messages in thread
From: Tomeu Vizoso @ 2016-09-15 10:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Tomeu Vizoso, Jon Hunter, Heiko Stuebner, Rafael J. Wysocki,
	Kevin Hilman, Ulf Hansson, Len Brown, Pavel Machek,
	Greg Kroah-Hartman, linux-pm

In platforms such as Rockchip's, the array of domains isn't always
filled without holes, as which domains are present depend on the
particular SoC revision.

By allowing holes to be in the array, such SoCs can still use a single
set of constants to index the array of power domains.

Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when adding a provider")
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Jon Hunter <jonathanh@nvidia.com>
Cc: Heiko Stuebner <heiko@sntech.de>
---
 drivers/base/power/domain.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index b0cf46dcae73..ce3f483ec67b 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1581,6 +1581,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 	mutex_lock(&gpd_list_lock);
 
 	for (i = 0; i < data->num_domains; i++) {
+		if (!data->domains[i])
+			continue;
 		if (!pm_genpd_present(data->domains[i]))
 			goto error;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] PM / Domains: Allow holes in genpd_data.domains array
  2016-09-15 10:39 [PATCH] PM / Domains: Allow holes in genpd_data.domains array Tomeu Vizoso
@ 2016-09-15 11:03   ` Jon Hunter
  0 siblings, 0 replies; 9+ messages in thread
From: Jon Hunter @ 2016-09-15 11:03 UTC (permalink / raw)
  To: Tomeu Vizoso, linux-kernel
  Cc: Heiko Stuebner, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Len Brown, Pavel Machek, Greg Kroah-Hartman, linux-pm


On 15/09/16 11:39, Tomeu Vizoso wrote:
> In platforms such as Rockchip's, the array of domains isn't always
> filled without holes, as which domains are present depend on the
> particular SoC revision.
> 
> By allowing holes to be in the array, such SoCs can still use a single
> set of constants to index the array of power domains.
> 
> Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when adding a provider")
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> ---
>  drivers/base/power/domain.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index b0cf46dcae73..ce3f483ec67b 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1581,6 +1581,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>  	mutex_lock(&gpd_list_lock);
>  
>  	for (i = 0; i < data->num_domains; i++) {
> +		if (!data->domains[i])
> +			continue;
>  		if (!pm_genpd_present(data->domains[i]))
>  			goto error;
>  

Sounds reasonable and sorry I had not thought of this. Can you also make
sure we check that !data->domains[i] in the error path as well or
potentially we could have a NULL pointer dereference in the case of an
actual error.

Cheers
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] PM / Domains: Allow holes in genpd_data.domains array
@ 2016-09-15 11:03   ` Jon Hunter
  0 siblings, 0 replies; 9+ messages in thread
From: Jon Hunter @ 2016-09-15 11:03 UTC (permalink / raw)
  To: Tomeu Vizoso, linux-kernel
  Cc: Heiko Stuebner, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Len Brown, Pavel Machek, Greg Kroah-Hartman, linux-pm


On 15/09/16 11:39, Tomeu Vizoso wrote:
> In platforms such as Rockchip's, the array of domains isn't always
> filled without holes, as which domains are present depend on the
> particular SoC revision.
> 
> By allowing holes to be in the array, such SoCs can still use a single
> set of constants to index the array of power domains.
> 
> Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when adding a provider")
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> ---
>  drivers/base/power/domain.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index b0cf46dcae73..ce3f483ec67b 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1581,6 +1581,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>  	mutex_lock(&gpd_list_lock);
>  
>  	for (i = 0; i < data->num_domains; i++) {
> +		if (!data->domains[i])
> +			continue;
>  		if (!pm_genpd_present(data->domains[i]))
>  			goto error;
>  

Sounds reasonable and sorry I had not thought of this. Can you also make
sure we check that !data->domains[i] in the error path as well or
potentially we could have a NULL pointer dereference in the case of an
actual error.

Cheers
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] PM / Domains: Allow holes in genpd_data.domains array
  2016-09-15 11:03   ` Jon Hunter
  (?)
@ 2016-09-15 12:05   ` Tomeu Vizoso
  2016-09-15 13:20       ` Jon Hunter
                       ` (3 more replies)
  -1 siblings, 4 replies; 9+ messages in thread
From: Tomeu Vizoso @ 2016-09-15 12:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: Tomeu Vizoso, Jon Hunter, Heiko Stuebner, Rafael J. Wysocki,
	Kevin Hilman, Ulf Hansson, Len Brown, Pavel Machek,
	Greg Kroah-Hartman, linux-pm

In platforms such as Rockchip's, the array of domains isn't always
filled without holes, as which domains are present depend on the
particular SoC revision.

By allowing holes to be in the array, such SoCs can still use a single
set of constants to index the array of power domains.

Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when adding a provider")
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Jon Hunter <jonathanh@nvidia.com>
Cc: Heiko Stuebner <heiko@sntech.de>

---

v2: Also skip holes in the error path.
---
 drivers/base/power/domain.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index b0cf46dcae73..83ae3d7d3fdd 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1581,6 +1581,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 	mutex_lock(&gpd_list_lock);
 
 	for (i = 0; i < data->num_domains; i++) {
+		if (!data->domains[i])
+			continue;
 		if (!pm_genpd_present(data->domains[i]))
 			goto error;
 
@@ -1598,6 +1600,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 
 error:
 	while (i--) {
+		if (!data->domains[i])
+			continue;
 		data->domains[i]->provider = NULL;
 		data->domains[i]->has_provider = false;
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PM / Domains: Allow holes in genpd_data.domains array
  2016-09-15 12:05   ` [PATCH v2] " Tomeu Vizoso
@ 2016-09-15 13:20       ` Jon Hunter
  2016-09-15 14:16     ` Ulf Hansson
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Jon Hunter @ 2016-09-15 13:20 UTC (permalink / raw)
  To: Tomeu Vizoso, linux-kernel
  Cc: Heiko Stuebner, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Len Brown, Pavel Machek, Greg Kroah-Hartman, linux-pm


On 15/09/16 13:05, Tomeu Vizoso wrote:
> In platforms such as Rockchip's, the array of domains isn't always
> filled without holes, as which domains are present depend on the
> particular SoC revision.
> 
> By allowing holes to be in the array, such SoCs can still use a single
> set of constants to index the array of power domains.
> 
> Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when adding a provider")
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> 
> ---
> 
> v2: Also skip holes in the error path.
> ---
>  drivers/base/power/domain.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index b0cf46dcae73..83ae3d7d3fdd 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1581,6 +1581,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>  	mutex_lock(&gpd_list_lock);
>  
>  	for (i = 0; i < data->num_domains; i++) {
> +		if (!data->domains[i])
> +			continue;
>  		if (!pm_genpd_present(data->domains[i]))
>  			goto error;
>  
> @@ -1598,6 +1600,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>  
>  error:
>  	while (i--) {
> +		if (!data->domains[i])
> +			continue;
>  		data->domains[i]->provider = NULL;
>  		data->domains[i]->has_provider = false;
>  	}
> 

Thanks!

Acked-by: Jon Hunter <jonathanh@nvidia.com>

Cheers
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PM / Domains: Allow holes in genpd_data.domains array
@ 2016-09-15 13:20       ` Jon Hunter
  0 siblings, 0 replies; 9+ messages in thread
From: Jon Hunter @ 2016-09-15 13:20 UTC (permalink / raw)
  To: Tomeu Vizoso, linux-kernel
  Cc: Heiko Stuebner, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Len Brown, Pavel Machek, Greg Kroah-Hartman, linux-pm


On 15/09/16 13:05, Tomeu Vizoso wrote:
> In platforms such as Rockchip's, the array of domains isn't always
> filled without holes, as which domains are present depend on the
> particular SoC revision.
> 
> By allowing holes to be in the array, such SoCs can still use a single
> set of constants to index the array of power domains.
> 
> Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when adding a provider")
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> 
> ---
> 
> v2: Also skip holes in the error path.
> ---
>  drivers/base/power/domain.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index b0cf46dcae73..83ae3d7d3fdd 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1581,6 +1581,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>  	mutex_lock(&gpd_list_lock);
>  
>  	for (i = 0; i < data->num_domains; i++) {
> +		if (!data->domains[i])
> +			continue;
>  		if (!pm_genpd_present(data->domains[i]))
>  			goto error;
>  
> @@ -1598,6 +1600,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>  
>  error:
>  	while (i--) {
> +		if (!data->domains[i])
> +			continue;
>  		data->domains[i]->provider = NULL;
>  		data->domains[i]->has_provider = false;
>  	}
> 

Thanks!

Acked-by: Jon Hunter <jonathanh@nvidia.com>

Cheers
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PM / Domains: Allow holes in genpd_data.domains array
  2016-09-15 12:05   ` [PATCH v2] " Tomeu Vizoso
  2016-09-15 13:20       ` Jon Hunter
@ 2016-09-15 14:16     ` Ulf Hansson
  2016-09-15 22:00     ` Heiko Stübner
  2016-09-16 16:13     ` Kevin Hilman
  3 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2016-09-15 14:16 UTC (permalink / raw)
  To: Tomeu Vizoso
  Cc: linux-kernel, Jon Hunter, Heiko Stuebner, Rafael J. Wysocki,
	Kevin Hilman, Len Brown, Pavel Machek, Greg Kroah-Hartman,
	linux-pm

On 15 September 2016 at 14:05, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
> In platforms such as Rockchip's, the array of domains isn't always
> filled without holes, as which domains are present depend on the
> particular SoC revision.
>
> By allowing holes to be in the array, such SoCs can still use a single
> set of constants to index the array of power domains.
>
> Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when adding a provider")
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Cc: Heiko Stuebner <heiko@sntech.de>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

>
> ---
>
> v2: Also skip holes in the error path.
> ---
>  drivers/base/power/domain.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index b0cf46dcae73..83ae3d7d3fdd 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1581,6 +1581,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>         mutex_lock(&gpd_list_lock);
>
>         for (i = 0; i < data->num_domains; i++) {
> +               if (!data->domains[i])
> +                       continue;
>                 if (!pm_genpd_present(data->domains[i]))
>                         goto error;
>
> @@ -1598,6 +1600,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>
>  error:
>         while (i--) {
> +               if (!data->domains[i])
> +                       continue;
>                 data->domains[i]->provider = NULL;
>                 data->domains[i]->has_provider = false;
>         }
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PM / Domains: Allow holes in genpd_data.domains array
  2016-09-15 12:05   ` [PATCH v2] " Tomeu Vizoso
  2016-09-15 13:20       ` Jon Hunter
  2016-09-15 14:16     ` Ulf Hansson
@ 2016-09-15 22:00     ` Heiko Stübner
  2016-09-16 16:13     ` Kevin Hilman
  3 siblings, 0 replies; 9+ messages in thread
From: Heiko Stübner @ 2016-09-15 22:00 UTC (permalink / raw)
  To: Tomeu Vizoso
  Cc: linux-kernel, Jon Hunter, Rafael J. Wysocki, Kevin Hilman,
	Ulf Hansson, Len Brown, Pavel Machek, Greg Kroah-Hartman,
	linux-pm

Am Donnerstag, 15. September 2016, 14:05:23 schrieb Tomeu Vizoso:
> In platforms such as Rockchip's, the array of domains isn't always
> filled without holes, as which domains are present depend on the
> particular SoC revision.
> 
> By allowing holes to be in the array, such SoCs can still use a single
> set of constants to index the array of power domains.
> 
> Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when
> adding a provider") Signed-off-by: Tomeu Vizoso
> <tomeu.vizoso@collabora.com>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Cc: Heiko Stuebner <heiko@sntech.de>

We talked about this today and the change looks good for handling the
holes in Rockchip power-domain lists, so

Reviewed-by: Heiko Stuebner <heiko@sntech.de>

also, on a rk3288-veyron Chromebook the display comes up again
with this patch (by not defering because of the missing domains), so

Tested-by: Heiko Stuebner <heiko@sntech.de>


Thanks
Heiko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PM / Domains: Allow holes in genpd_data.domains array
  2016-09-15 12:05   ` [PATCH v2] " Tomeu Vizoso
                       ` (2 preceding siblings ...)
  2016-09-15 22:00     ` Heiko Stübner
@ 2016-09-16 16:13     ` Kevin Hilman
  3 siblings, 0 replies; 9+ messages in thread
From: Kevin Hilman @ 2016-09-16 16:13 UTC (permalink / raw)
  To: Tomeu Vizoso
  Cc: linux-kernel, Jon Hunter, Heiko Stuebner, Rafael J. Wysocki,
	Ulf Hansson, Len Brown, Pavel Machek, Greg Kroah-Hartman,
	linux-pm

Tomeu Vizoso <tomeu.vizoso@collabora.com> writes:

> In platforms such as Rockchip's, the array of domains isn't always
> filled without holes, as which domains are present depend on the
> particular SoC revision.
>
> By allowing holes to be in the array, such SoCs can still use a single
> set of constants to index the array of power domains.
>
> Fixes: 0159ec670763 ("PM / Domains: Verify the PM domain is present when adding a provider")
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
>
> ---
>
> v2: Also skip holes in the error path.

Acked-by: Kevin Hilman <khilman@baylibre.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-09-16 16:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15 10:39 [PATCH] PM / Domains: Allow holes in genpd_data.domains array Tomeu Vizoso
2016-09-15 11:03 ` Jon Hunter
2016-09-15 11:03   ` Jon Hunter
2016-09-15 12:05   ` [PATCH v2] " Tomeu Vizoso
2016-09-15 13:20     ` Jon Hunter
2016-09-15 13:20       ` Jon Hunter
2016-09-15 14:16     ` Ulf Hansson
2016-09-15 22:00     ` Heiko Stübner
2016-09-16 16:13     ` Kevin Hilman

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.