linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, Wenyou.Yang@microchip.com,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [PATCH 3/3] ARM: at91: pm: fallback to slowclock when backup mode fails
Date: Wed, 26 Apr 2017 18:04:19 +0200	[thread overview]
Message-ID: <20170426160419.22401-3-alexandre.belloni@free-electrons.com> (raw)
In-Reply-To: <20170426160419.22401-1-alexandre.belloni@free-electrons.com>

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(-)

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 {
-- 
2.11.0

  parent reply	other threads:[~2017-04-26 16:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 16:04 [PATCH 1/3] ARM: at91: pm: Add sama5d2 backup mode Alexandre Belloni
2017-04-26 16:04 ` [PATCH 2/3] ARM: at91: pm: allow selecting standby and suspend modes Alexandre Belloni
2017-04-28  1:33   ` Yang, Wenyou
2017-04-26 16:04 ` Alexandre Belloni [this message]
2017-04-28  1:34   ` [PATCH 3/3] ARM: at91: pm: fallback to slowclock when backup mode fails Yang, Wenyou
2017-04-27 13:34 ` [PATCH 1/3] ARM: at91: pm: Add sama5d2 backup mode Romain Izard
2017-04-27 14:41   ` Alexandre Belloni
2017-04-28  1:25 ` Yang, Wenyou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170426160419.22401-3-alexandre.belloni@free-electrons.com \
    --to=alexandre.belloni@free-electrons.com \
    --cc=Wenyou.Yang@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).