diff mbox

[v2] PM / Domains: Allow holes in genpd_data.domains array

Message ID 1473941123-15090-1-git-send-email-tomeu.vizoso@collabora.com (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Tomeu Vizoso Sept. 15, 2016, 12:05 p.m. UTC
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(+)

Comments

Jon Hunter Sept. 15, 2016, 1:20 p.m. UTC | #1
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
Ulf Hansson Sept. 15, 2016, 2:16 p.m. UTC | #2
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
>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Heiko Stübner Sept. 15, 2016, 10 p.m. UTC | #3
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
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kevin Hilman Sept. 16, 2016, 4:13 p.m. UTC | #4
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>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;
 	}