linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: Problem with atomic accesses in pstore on some ARM CPUs
Date: Mon, 15 Aug 2016 23:15:18 +0100	[thread overview]
Message-ID: <20160815221518.GD1120@svinekod> (raw)
In-Reply-To: <CABXOdTfHX_ZB1CuM7hzU5LCZPYdHvBSatN9Nen=rb8r1rXhz-g@mail.gmail.com>

On Tue, Aug 16, 2016 at 08:02:53AM -0700, Guenter Roeck wrote:
> On Tue, Aug 16, 2016 at 6:21 AM, Will Deacon <will.deacon@arm.com> wrote:
> > On Tue, Aug 16, 2016 at 06:14:53AM -0700, Guenter Roeck wrote:
> >> On Tue, Aug 16, 2016 at 3:32 AM, Robin Murphy <robin.murphy@arm.com> wrote:
> >> > On 16/08/16 00:19, Guenter Roeck wrote:
> >> >> we are having a problem with atomic accesses in pstore on some ARM
> >> >> CPUs (specifically rk3288 and rk3399). With those chips, atomic
> >> >> accesses fail with both pgprot_noncached and pgprot_writecombine
> >> >> memory. Atomic accesses do work when selecting PAGE_KERNEL protection.
> >> >
> >> > What's the pstore backed by? I'm guessing it's not normal DRAM.
> >> >
> >>
> >> it is normal DRAM.
> >
> > In which case, why does it need to be mapped with weird attributes?
> > Is there an alias in the linear map you can use?
> >
> 
> I don't really _want_ to do anything besides using pstore as-is, or,
> in other words, to have the upstream kernel work with the affected
> systems.
> 
> The current pstore code runs the following code for memory with
> pfn_valid() = true.
> 
>         if (memtype)
>                 prot = pgprot_noncached(PAGE_KERNEL);
>         else
>                 prot = pgprot_writecombine(PAGE_KERNEL);
>         ...
>         vaddr = vmap(pages, page_count, VM_MAP, prot);
> 
> It then uses the memory pointed to by vaddr for atomic operations.

This means that the generic ramoops / pstore code is making non-portable
assumptions about memory types.

So _something_ has to happen to that code.

> In my case, both protection options don't work. Everything works fine
> (or at least doesn't create an exception) if I use
>         vaddr = vmap(pages, page_count, VM_MAP, PAGE_KERNEL);
> instead.

Architecturally, that will give you a memory type to which we can safely use
atomics on.

It would be nice to know why the ramoops/pstore code must use atomics, and
exactly what it's trying to achieve (i.e. is this just for serialisation, or an
attempt to ensure persistence).

Depending on that, it may be possible to fix things more generically by using
memremap by default, for example, and only allowing uncached mappings on those
architectures which support them.

Thanks,
Mark.

  reply	other threads:[~2016-08-15 22:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-15 23:19 Problem with atomic accesses in pstore on some ARM CPUs Guenter Roeck
2016-08-16 10:32 ` Robin Murphy
2016-08-16 10:45   ` Will Deacon
2016-08-16 13:21     ` Guenter Roeck
2016-08-16 13:14   ` Guenter Roeck
2016-08-16 13:21     ` Will Deacon
2016-08-16 15:02       ` Guenter Roeck
2016-08-15 22:15         ` Mark Rutland [this message]
2016-08-16 17:35           ` Colin Cross
2016-08-16 20:26             ` Guenter Roeck
2016-08-16 20:50               ` Kees Cook
2016-08-17  0:26                 ` Guenter Roeck
2016-08-18 14:02                   ` Tony Lindgren
2016-08-19  9:35             ` Russell King - ARM Linux
2016-08-19 12:47               ` Guenter Roeck
2016-08-22 21:03           ` Arnd Bergmann

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=20160815221518.GD1120@svinekod \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).