[PATCH] misc/genalloc: Name subpools by of_node_full_name()

Linus Walleij posted 1 patch 2 years, 7 months ago
drivers/misc/sram.c | 2 +-
lib/genalloc.c      | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[PATCH] misc/genalloc: Name subpools by of_node_full_name()
Posted by Linus Walleij 2 years, 7 months ago
A previous commit tried to come up with more generic subpool
names, but this isn't quite working: the node name was used
elsewhere to match pools to consumers which regressed the
nVidia Tegra 2/3 video decoder.

Revert back to an earlier approach using of_node_full_name()
instead of just the name to make sure the pool name is more
unique, and change both sites using this in the kernel.

It is not perfect since two SRAM nodes could have the same
subpool name but it makes the situation better than before.

Reported-by: Dmitry Osipenko <digetx@gmail.com>
Fixes: 21e5a2d10c8f ("misc: sram: Generate unique names for subpools")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/misc/sram.c | 2 +-
 lib/genalloc.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index 5757adf418b1..61209739dc43 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -236,7 +236,7 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
 			}
 			if (!label)
 				block->label = devm_kasprintf(sram->dev, GFP_KERNEL,
-							      "%s", dev_name(sram->dev));
+							      "%s", of_node_full_name(child));
 			else
 				block->label = devm_kstrdup(sram->dev,
 							    label, GFP_KERNEL);
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 0c883d6fbd44..6c644f954bc5 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -895,7 +895,7 @@ struct gen_pool *of_gen_pool_get(struct device_node *np,
 
 		of_property_read_string(np_pool, "label", &name);
 		if (!name)
-			name = np_pool->name;
+			name = of_node_full_name(np_pool);
 	}
 	if (pdev)
 		pool = gen_pool_get(&pdev->dev, name);
-- 
2.34.1
Re: [PATCH] misc/genalloc: Name subpools by of_node_full_name()
Posted by Linus Walleij 2 years, 6 months ago
Greg, could you apply this patch for fixes?

Thanks!

On Thu, Jun 22, 2023 at 9:45 AM Linus Walleij <linus.walleij@linaro.org> wrote:

> A previous commit tried to come up with more generic subpool
> names, but this isn't quite working: the node name was used
> elsewhere to match pools to consumers which regressed the
> nVidia Tegra 2/3 video decoder.
>
> Revert back to an earlier approach using of_node_full_name()
> instead of just the name to make sure the pool name is more
> unique, and change both sites using this in the kernel.
>
> It is not perfect since two SRAM nodes could have the same
> subpool name but it makes the situation better than before.
>
> Reported-by: Dmitry Osipenko <digetx@gmail.com>
> Fixes: 21e5a2d10c8f ("misc: sram: Generate unique names for subpools")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Re: [PATCH] misc/genalloc: Name subpools by of_node_full_name()
Posted by Greg Kroah-Hartman 2 years, 6 months ago
On Sun, Jul 16, 2023 at 09:44:39AM +0200, Linus Walleij wrote:
> Greg, could you apply this patch for fixes?
> 
> Thanks!
> 
> On Thu, Jun 22, 2023 at 9:45 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> 
> > A previous commit tried to come up with more generic subpool
> > names, but this isn't quite working: the node name was used
> > elsewhere to match pools to consumers which regressed the
> > nVidia Tegra 2/3 video decoder.
> >
> > Revert back to an earlier approach using of_node_full_name()
> > instead of just the name to make sure the pool name is more
> > unique, and change both sites using this in the kernel.
> >
> > It is not perfect since two SRAM nodes could have the same
> > subpool name but it makes the situation better than before.
> >
> > Reported-by: Dmitry Osipenko <digetx@gmail.com>
> > Fixes: 21e5a2d10c8f ("misc: sram: Generate unique names for subpools")
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Let me catch up with emails over the next week or so, I'll queue it up
then, thanks.

greg k-h
Re: [PATCH] misc/genalloc: Name subpools by of_node_full_name()
Posted by Dmitry Osipenko 2 years, 7 months ago
22.06.2023 10:45, Linus Walleij пишет:
> A previous commit tried to come up with more generic subpool
> names, but this isn't quite working: the node name was used
> elsewhere to match pools to consumers which regressed the
> nVidia Tegra 2/3 video decoder.
> 
> Revert back to an earlier approach using of_node_full_name()
> instead of just the name to make sure the pool name is more
> unique, and change both sites using this in the kernel.
> 
> It is not perfect since two SRAM nodes could have the same
> subpool name but it makes the situation better than before.
> 
> Reported-by: Dmitry Osipenko <digetx@gmail.com>
> Fixes: 21e5a2d10c8f ("misc: sram: Generate unique names for subpools")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/misc/sram.c | 2 +-
>  lib/genalloc.c      | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
> index 5757adf418b1..61209739dc43 100644
> --- a/drivers/misc/sram.c
> +++ b/drivers/misc/sram.c
> @@ -236,7 +236,7 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
>  			}
>  			if (!label)
>  				block->label = devm_kasprintf(sram->dev, GFP_KERNEL,
> -							      "%s", dev_name(sram->dev));
> +							      "%s", of_node_full_name(child));
>  			else
>  				block->label = devm_kstrdup(sram->dev,
>  							    label, GFP_KERNEL);
> diff --git a/lib/genalloc.c b/lib/genalloc.c
> index 0c883d6fbd44..6c644f954bc5 100644
> --- a/lib/genalloc.c
> +++ b/lib/genalloc.c
> @@ -895,7 +895,7 @@ struct gen_pool *of_gen_pool_get(struct device_node *np,
>  
>  		of_property_read_string(np_pool, "label", &name);
>  		if (!name)
> -			name = np_pool->name;
> +			name = of_node_full_name(np_pool);
>  	}
>  	if (pdev)
>  		pool = gen_pool_get(&pdev->dev, name);

Works great, thanks!

Tested-by: Dmitry Osipenko <digetx@gmail.com>