diff mbox

[3/3] ARM: at91: pm: fallback to slowclock when backup mode fails

Message ID 20170426160419.22401-3-alexandre.belloni@free-electrons.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexandre Belloni April 26, 2017, 4:04 p.m. UTC
If the backup sram allocation fails, ensure we can suspend by falling back
to the usual slow clock mode.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/mach-at91/pm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Wenyou.Yang@microchip.com April 28, 2017, 1:34 a.m. UTC | #1
On 2017/4/27 0:04, Alexandre Belloni wrote:
> If the backup sram allocation fails, ensure we can suspend by falling back
> to the usual slow clock mode.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Wenyou Yang <wenyou.yang@atmel.com>

> ---
>   arch/arm/mach-at91/pm.c | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index d08f032f9d94..02823d8f3ada 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -519,24 +519,30 @@ static void __init at91_pm_bu_sram_init(void)
>   
>   	if (!pdev) {
>   		pr_warn("%s: failed to find securam device!\n", __func__);
> -		return;
> +		goto fallback;
>   	}
>   
>   	sram_pool = gen_pool_get(&pdev->dev, NULL);
>   	if (!sram_pool) {
>   		pr_warn("%s: securam pool unavailable!\n", __func__);
> -		return;
> +		goto fallback;
>   	}
>   
>   	pm_bu = (void *)gen_pool_alloc(sram_pool, sizeof(struct at91_pm_bu));
>   	if (!pm_bu) {
>   		pr_warn("%s: unable to alloc securam!\n", __func__);
> -		return;
> +		goto fallback;
>   	}
>   
>   	pm_bu->suspended = 0;
>   	pm_bu->canary = virt_to_phys(&canary);
>   	pm_bu->resume = virt_to_phys(cpu_resume);
> +
> +fallback:
> +	if (pm_data.standby_mode == AT91_PM_BACKUP)
> +		pm_data.standby_mode = AT91_PM_SLOW_CLOCK;
> +	if (pm_data.suspend_mode != AT91_PM_BACKUP)
> +		pm_data.suspend_mode = AT91_PM_SLOW_CLOCK;
>   }
>   
>   struct pmc_info {
Best Regards,
Wenyou Yang
diff mbox

Patch

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index d08f032f9d94..02823d8f3ada 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -519,24 +519,30 @@  static void __init at91_pm_bu_sram_init(void)
 
 	if (!pdev) {
 		pr_warn("%s: failed to find securam device!\n", __func__);
-		return;
+		goto fallback;
 	}
 
 	sram_pool = gen_pool_get(&pdev->dev, NULL);
 	if (!sram_pool) {
 		pr_warn("%s: securam pool unavailable!\n", __func__);
-		return;
+		goto fallback;
 	}
 
 	pm_bu = (void *)gen_pool_alloc(sram_pool, sizeof(struct at91_pm_bu));
 	if (!pm_bu) {
 		pr_warn("%s: unable to alloc securam!\n", __func__);
-		return;
+		goto fallback;
 	}
 
 	pm_bu->suspended = 0;
 	pm_bu->canary = virt_to_phys(&canary);
 	pm_bu->resume = virt_to_phys(cpu_resume);
+
+fallback:
+	if (pm_data.standby_mode == AT91_PM_BACKUP)
+		pm_data.standby_mode = AT91_PM_SLOW_CLOCK;
+	if (pm_data.suspend_mode != AT91_PM_BACKUP)
+		pm_data.suspend_mode = AT91_PM_SLOW_CLOCK;
 }
 
 struct pmc_info {