linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
@ 2020-06-04 12:33 yu kuai
  2020-06-24  8:46 ` yukuai (C)
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: yu kuai @ 2020-06-04 12:33 UTC (permalink / raw)
  To: linux, nicolas.ferre, alexandre.belloni, ludovic.desroches
  Cc: yukuai3, linux-kernel, linux-arm-kernel, yi.zhang

if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have
a corresponding put_device(). Thus add a jump target to fix the exception
handling for this function implementation.

Fixes: d2e467905596 ("ARM: at91: pm: use the mmio-sram pool to access SRAM")
Signed-off-by: yu kuai <yukuai3@huawei.com>
---
 arch/arm/mach-at91/pm.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 074bde64064e..2aab043441e8 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -592,13 +592,13 @@ static void __init at91_pm_sram_init(void)
 	sram_pool = gen_pool_get(&pdev->dev, NULL);
 	if (!sram_pool) {
 		pr_warn("%s: sram pool unavailable!\n", __func__);
-		return;
+		goto out_put_device;
 	}
 
 	sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
 	if (!sram_base) {
 		pr_warn("%s: unable to alloc sram!\n", __func__);
-		return;
+		goto out_put_device;
 	}
 
 	sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
@@ -606,12 +606,17 @@ static void __init at91_pm_sram_init(void)
 					at91_pm_suspend_in_sram_sz, false);
 	if (!at91_suspend_sram_fn) {
 		pr_warn("SRAM: Could not map\n");
-		return;
+		goto out_put_device;
 	}
 
 	/* Copy the pm suspend handler to SRAM */
 	at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
 			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
+	return;
+
+out_put_device:
+	put_device(&pdev->dev);
+	return;
 }
 
 static bool __init at91_is_pm_mode_active(int pm_mode)
-- 
2.25.4


_______________________________________________
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] 7+ messages in thread

* Re: [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
  2020-06-04 12:33 [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init() yu kuai
@ 2020-06-24  8:46 ` yukuai (C)
  2020-07-02 20:09 ` Alexandre Belloni
  2020-07-17 23:00 ` Alexandre Belloni
  2 siblings, 0 replies; 7+ messages in thread
From: yukuai (C) @ 2020-06-24  8:46 UTC (permalink / raw)
  To: linux, nicolas.ferre, alexandre.belloni, ludovic.desroches
  Cc: linux-kernel, linux-arm-kernel, yi.zhang

ping?

On 2020/6/4 20:33, yu kuai wrote:
> if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have
> a corresponding put_device(). Thus add a jump target to fix the exception
> handling for this function implementation.
> 
> Fixes: d2e467905596 ("ARM: at91: pm: use the mmio-sram pool to access SRAM")
> Signed-off-by: yu kuai <yukuai3@huawei.com>
> ---
>   arch/arm/mach-at91/pm.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 074bde64064e..2aab043441e8 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -592,13 +592,13 @@ static void __init at91_pm_sram_init(void)
>   	sram_pool = gen_pool_get(&pdev->dev, NULL);
>   	if (!sram_pool) {
>   		pr_warn("%s: sram pool unavailable!\n", __func__);
> -		return;
> +		goto out_put_device;
>   	}
>   
>   	sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
>   	if (!sram_base) {
>   		pr_warn("%s: unable to alloc sram!\n", __func__);
> -		return;
> +		goto out_put_device;
>   	}
>   
>   	sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
> @@ -606,12 +606,17 @@ static void __init at91_pm_sram_init(void)
>   					at91_pm_suspend_in_sram_sz, false);
>   	if (!at91_suspend_sram_fn) {
>   		pr_warn("SRAM: Could not map\n");
> -		return;
> +		goto out_put_device;
>   	}
>   
>   	/* Copy the pm suspend handler to SRAM */
>   	at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
>   			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
> +	return;
> +
> +out_put_device:
> +	put_device(&pdev->dev);
> +	return;
>   }
>   
>   static bool __init at91_is_pm_mode_active(int pm_mode)
> 


_______________________________________________
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] 7+ messages in thread

* Re: [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
  2020-06-04 12:33 [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init() yu kuai
  2020-06-24  8:46 ` yukuai (C)
@ 2020-07-02 20:09 ` Alexandre Belloni
  2020-07-03  1:15   ` yukuai (C)
  2020-07-17 23:00 ` Alexandre Belloni
  2 siblings, 1 reply; 7+ messages in thread
From: Alexandre Belloni @ 2020-07-02 20:09 UTC (permalink / raw)
  To: yu kuai; +Cc: yi.zhang, linux-kernel, linux, ludovic.desroches,
	linux-arm-kernel

Hi,

On 04/06/2020 20:33:01+0800, yu kuai wrote:
> if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have
> a corresponding put_device(). Thus add a jump target to fix the exception
> handling for this function implementation.
> 
> Fixes: d2e467905596 ("ARM: at91: pm: use the mmio-sram pool to access SRAM")
> Signed-off-by: yu kuai <yukuai3@huawei.com>
> ---
>  arch/arm/mach-at91/pm.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 074bde64064e..2aab043441e8 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -592,13 +592,13 @@ static void __init at91_pm_sram_init(void)
>  	sram_pool = gen_pool_get(&pdev->dev, NULL);

Isn't the best solution to simply have put_device here?

>  	if (!sram_pool) {
>  		pr_warn("%s: sram pool unavailable!\n", __func__);
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
>  	if (!sram_base) {
>  		pr_warn("%s: unable to alloc sram!\n", __func__);
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
> @@ -606,12 +606,17 @@ static void __init at91_pm_sram_init(void)
>  					at91_pm_suspend_in_sram_sz, false);
>  	if (!at91_suspend_sram_fn) {
>  		pr_warn("SRAM: Could not map\n");
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	/* Copy the pm suspend handler to SRAM */
>  	at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
>  			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
> +	return;
> +
> +out_put_device:
> +	put_device(&pdev->dev);
> +	return;
>  }
>  
>  static bool __init at91_is_pm_mode_active(int pm_mode)
> -- 
> 2.25.4
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
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] 7+ messages in thread

* Re: [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
  2020-07-02 20:09 ` Alexandre Belloni
@ 2020-07-03  1:15   ` yukuai (C)
  2020-07-17 22:55     ` Alexandre Belloni
  0 siblings, 1 reply; 7+ messages in thread
From: yukuai (C) @ 2020-07-03  1:15 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: yi.zhang, linux-kernel, linux, ludovic.desroches,
	linux-arm-kernel


On 2020/7/3 4:09, Alexandre Belloni wrote:
> Hi,
> 
> On 04/06/2020 20:33:01+0800, yu kuai wrote:
>> if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have
>> a corresponding put_device(). Thus add a jump target to fix the exception
>> handling for this function implementation.
>>
>> Fixes: d2e467905596 ("ARM: at91: pm: use the mmio-sram pool to access SRAM")
>> Signed-off-by: yu kuai <yukuai3@huawei.com>
>> ---
>>   arch/arm/mach-at91/pm.c | 11 ++++++++---
>>   1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
>> index 074bde64064e..2aab043441e8 100644
>> --- a/arch/arm/mach-at91/pm.c
>> +++ b/arch/arm/mach-at91/pm.c
>> @@ -592,13 +592,13 @@ static void __init at91_pm_sram_init(void)
>>   	sram_pool = gen_pool_get(&pdev->dev, NULL);
> 
> Isn't the best solution to simply have put_device hereHi, Alexandre !

I think put_device() is supposed to be called in the exception handling
path.

> 
>>   	if (!sram_pool) {
>>   		pr_warn("%s: sram pool unavailable!\n", __func__);
>> -		return;
>> +		goto out_put_device;
>>   	}
>>   
>>   	sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
>>   	if (!sram_base) {
>>   		pr_warn("%s: unable to alloc sram!\n", __func__);
>> -		return;
>> +		goto out_put_device;
>>   	}
>>   
>>   	sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
>> @@ -606,12 +606,17 @@ static void __init at91_pm_sram_init(void)
>>   					at91_pm_suspend_in_sram_sz, false);
>>   	if (!at91_suspend_sram_fn) {
>>   		pr_warn("SRAM: Could not map\n");
>> -		return;
>> +		goto out_put_device;
>>   	}
>>   
>>   	/* Copy the pm suspend handler to SRAM */
>>   	at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
>>   			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);

If nothing is wrong, maybe put_device shounld't be called?

Thanks!
Yu Kuai
>> +	return;
>> +
>> +out_put_device:
>> +	put_device(&pdev->dev);
>> +	return;
>>   }
>>   
>>   static bool __init at91_is_pm_mode_active(int pm_mode)
>> -- 
>> 2.25.4
>>
> 


_______________________________________________
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] 7+ messages in thread

* Re: [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
  2020-07-03  1:15   ` yukuai (C)
@ 2020-07-17 22:55     ` Alexandre Belloni
  2020-07-21 13:11       ` yukuai (C)
  0 siblings, 1 reply; 7+ messages in thread
From: Alexandre Belloni @ 2020-07-17 22:55 UTC (permalink / raw)
  To: yukuai (C)
  Cc: yi.zhang, linux-kernel, linux, ludovic.desroches,
	linux-arm-kernel

On 03/07/2020 09:15:20+0800, yukuai (C) wrote:
> 
> On 2020/7/3 4:09, Alexandre Belloni wrote:
> > Hi,
> > 
> > On 04/06/2020 20:33:01+0800, yu kuai wrote:
> > > if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have
> > > a corresponding put_device(). Thus add a jump target to fix the exception
> > > handling for this function implementation.
> > > 
> > > Fixes: d2e467905596 ("ARM: at91: pm: use the mmio-sram pool to access SRAM")
> > > Signed-off-by: yu kuai <yukuai3@huawei.com>
> > > ---
> > >   arch/arm/mach-at91/pm.c | 11 ++++++++---
> > >   1 file changed, 8 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> > > index 074bde64064e..2aab043441e8 100644
> > > --- a/arch/arm/mach-at91/pm.c
> > > +++ b/arch/arm/mach-at91/pm.c
> > > @@ -592,13 +592,13 @@ static void __init at91_pm_sram_init(void)
> > >   	sram_pool = gen_pool_get(&pdev->dev, NULL);
> > 
> > Isn't the best solution to simply have put_device hereHi, Alexandre !
> 
> I think put_device() is supposed to be called in the exception handling
> path.
> 
> > 
> > >   	if (!sram_pool) {
> > >   		pr_warn("%s: sram pool unavailable!\n", __func__);
> > > -		return;
> > > +		goto out_put_device;
> > >   	}
> > >   	sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
> > >   	if (!sram_base) {
> > >   		pr_warn("%s: unable to alloc sram!\n", __func__);
> > > -		return;
> > > +		goto out_put_device;
> > >   	}
> > >   	sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
> > > @@ -606,12 +606,17 @@ static void __init at91_pm_sram_init(void)
> > >   					at91_pm_suspend_in_sram_sz, false);
> > >   	if (!at91_suspend_sram_fn) {
> > >   		pr_warn("SRAM: Could not map\n");
> > > -		return;
> > > +		goto out_put_device;
> > >   	}
> > >   	/* Copy the pm suspend handler to SRAM */
> > >   	at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
> > >   			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
> 
> If nothing is wrong, maybe put_device shounld't be called?
> 

I don't think this is the case but as the reference implementation
(imx6) is carrying the patch, I'm going to apply this one.

A better fix would have been to also factorize imx_suspend_alloc_ocram,
imx6q_suspend_init, socfpga_setup_ocram_self_refresh and
at91_pm_sram_init as they were all copied from pm-imx6.c


-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
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] 7+ messages in thread

* Re: [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
  2020-06-04 12:33 [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init() yu kuai
  2020-06-24  8:46 ` yukuai (C)
  2020-07-02 20:09 ` Alexandre Belloni
@ 2020-07-17 23:00 ` Alexandre Belloni
  2 siblings, 0 replies; 7+ messages in thread
From: Alexandre Belloni @ 2020-07-17 23:00 UTC (permalink / raw)
  To: yu kuai, ludovic.desroches, nicolas.ferre, linux
  Cc: Alexandre Belloni, linux-kernel, linux-arm-kernel, yi.zhang

On Thu, 4 Jun 2020 20:33:01 +0800, yu kuai wrote:
> if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have
> a corresponding put_device(). Thus add a jump target to fix the exception
> handling for this function implementation.

Applied, thanks!

[1/1] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
      commit: f87a4f022c44e5b87e842a9f3e644fba87e8385f

Best regards,
-- 
Alexandre Belloni <alexandre.belloni@bootlin.com>

_______________________________________________
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] 7+ messages in thread

* Re: [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
  2020-07-17 22:55     ` Alexandre Belloni
@ 2020-07-21 13:11       ` yukuai (C)
  0 siblings, 0 replies; 7+ messages in thread
From: yukuai (C) @ 2020-07-21 13:11 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: yi.zhang, linux-kernel, linux, ludovic.desroches,
	linux-arm-kernel

On 2020/7/18 6:55, Alexandre Belloni wrote:

> A better fix would have been to also factorize imx_suspend_alloc_ocram,
> imx6q_suspend_init, socfpga_setup_ocram_self_refresh and
> at91_pm_sram_init as they were all copied from pm-imx6.c
> 
imx_suspend_alloc_ocram and imx6q_suspend_init are done areadly,
socfpga_setup_ocram_self_refresh and at91_pm_sram_init still need to
fix. Thanks for pointing out!

Yu Kuai


_______________________________________________
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] 7+ messages in thread

end of thread, other threads:[~2020-07-21 13:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-04 12:33 [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init() yu kuai
2020-06-24  8:46 ` yukuai (C)
2020-07-02 20:09 ` Alexandre Belloni
2020-07-03  1:15   ` yukuai (C)
2020-07-17 22:55     ` Alexandre Belloni
2020-07-21 13:11       ` yukuai (C)
2020-07-17 23:00 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).