linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Capella <sebastian.capella@linaro.org>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Len Brown <len.brown@intel.com>,
	"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>,
	Russell King <linux@arm.linux.org.uk>,
	Jonathan Austin <Jonathan.Austin@arm.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Will Deacon <Will.Deacon@arm.com>,
	Nicolas Pitre <nico@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>,
	Russ Dill <Russ.Dill@ti.com>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v6 2/2] ARM hibernation / suspend-to-disk
Date: Fri, 28 Feb 2014 12:15:57 -0800	[thread overview]
Message-ID: <20140228201557.29118.62126@capellas-linux> (raw)
In-Reply-To: <20140228095022.GA25090@e102568-lin.cambridge.arm.com>

Sorry, I appear to be having problems with my emails where list emails are
bouncing back to me.  I'm working on correcting this now.

Quoting Lorenzo Pieralisi (2014-02-28 01:50:22)
> On Thu, Feb 27, 2014 at 11:57:58PM +0000, Sebastian Capella wrote:
> 
> [...]
> 
> > diff --git a/arch/arm/kernel/hibernate.c b/arch/arm/kernel/hibernate.c
> > new file mode 100644
> > index 0000000..a41e0e3
> > --- /dev/null
> > +++ b/arch/arm/kernel/hibernate.c
...
> > +#include <linux/suspend.h>
> > +#include <asm/tlbflush.h>
> > +#include <asm/cacheflush.h>
> 
> You can drop tlbflush.h and cacheflush.h, they do not seem to be needed.

Done! Thanks!

> > +
> > +/*
> > + * The framework loads the hibernation image into a linked list anchored
> > + * at restore_pblist, for swsusp_arch_resume() to copy back to the proper
> > + * destinations.
> > + *
> > + * To make this work if resume is triggered from initramfs, the
> > + * pagetables need to be switched to allow writes to kernel mem.
> > + */
> 
> Comment above needs updating. We are switching page tables to a set of
> page tables that are certain to live at the same location in the older
> kernel, that's the only reason, as we discussed. soft_restart will make
> sure (again) to switch to 1:1 page tables so that we can call cpu_resume
> with the MMU off.

How does this look?

The framework loads as much of the hibernation image to final physical
pages as possible.  Any pages that were in use, will need to be restored
prior to the soft_restart.  The pages to restore are maintained in
the list anchored at restore_pblist.  At this point, we can swap the
pages to their final location.  We must switch the mapping to 1:1 to
ensure that when we overwrite the page table physical pages we're using
a known physical location (idmap_pgd) with known contents.

> > +/*
> > + * Resume from the hibernation image.
> > + * Due to the kernel heap / data restore, stack contents change underneath
> > + * and that would make function calls impossible; switch to a temporary
> > + * stack within the nosave region to avoid that problem.
> > + */
> > +int swsusp_arch_resume(void)
> > +{
> > +     extern void call_with_stack(void (*fn)(void *), void *arg, void *sp);
> > +     call_with_stack(arch_restore_image, 0,
> > +             resume_stack + sizeof(resume_stack));
> 
> This does not guarantee your stack is 8-byte aligned, that's not AAPCS
> compliant and might buy you trouble.
> 
> Either you align the stack or you align the pointer you are passing.
> 
> Please have a look at kernel/process.c

I've added this for now, do you see any issues?

-static u8 resume_stack[PAGE_SIZE/2] __nosavedata;
+static u64 resume_stack[PAGE_SIZE/2/sizeof(u64)] __nosavedata;
-               resume_stack + sizeof(resume_stack));
+               resume_stack + ARRAY_SIZE(resume_stack));

Thanks Lorenzo!

Sebastian

  reply	other threads:[~2014-02-28 20:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27 23:57 [PATCH v6 0/2] hibernation support on ARM Sebastian Capella
2014-02-27 23:57 ` [PATCH v6 1/2] ARM: avoid tracers in soft_restart Sebastian Capella
2014-02-27 23:57 ` [PATCH v6 2/2] ARM hibernation / suspend-to-disk Sebastian Capella
2014-02-28  0:09   ` Stephen Boyd
2014-02-28  1:47     ` Russ Dill
2014-02-28  2:19       ` Stephen Boyd
2014-02-28 10:20         ` Russell King - ARM Linux
     [not found]           ` <20140228181731.29118.41809@capellas-linux>
2014-03-05  2:28             ` Sebastian Capella
2014-06-02 16:57               ` Sebastian Capella
2014-02-28  9:50   ` Lorenzo Pieralisi
2014-02-28 20:15     ` Sebastian Capella [this message]
2014-02-28 22:49       ` Lorenzo Pieralisi
2014-02-28 23:38         ` Sebastian Capella
2014-03-04  9:55           ` Sebastian Capella
2014-03-04 11:17             ` Lorenzo Pieralisi
2014-03-05  0:18               ` Sebastian Capella

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=20140228201557.29118.62126@capellas-linux \
    --to=sebastian.capella@linaro.org \
    --cc=Catalin.Marinas@arm.com \
    --cc=Jonathan.Austin@arm.com \
    --cc=Russ.Dill@ti.com \
    --cc=Will.Deacon@arm.com \
    --cc=len.brown@intel.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=nico@linaro.org \
    --cc=rjw@rjwysocki.net \
    --cc=santosh.shilimkar@ti.com \
    --cc=sboyd@codeaurora.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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).