Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1466353

Re: Problem with atomic accesses in pstore on some ARM CPUs

From Guenter Roeck <groeck@google.com>
Newsgroups linux.kernel
Subject Re: Problem with atomic accesses in pstore on some ARM CPUs
Date 2016-08-19 14:50 +0200
Message-ID <s7Rpg-5FZ-33@gated-at.bofh.it> (permalink)
References (3 earlier) <s6MBj-3Dm-5@gated-at.bofh.it> <s6OjL-4IB-1@gated-at.bofh.it> <s6QlA-5Yr-15@gated-at.bofh.it> <s6QEV-64O-15@gated-at.bofh.it> <s7Orn-3RM-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Aug 19, 2016 at 2:35 AM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Tue, Aug 16, 2016 at 10:35:52AM -0700, Colin Cross wrote:
>> persistent_ram uses atomic ops in uncached memory to store the start
>> and end positions in the ringbuffer so that the state of the
>> ringbuffer will be valid if the kernel crashes at any time.  This was
>> inherited from Android's ram_console implementation, and worked
>> through armv7.
>
> That statement is actually inaccurate.  It may have worked on _some_
> ARMv7 implementations, but it's not architecturally compliant.
>
> The exclusive access instructions are not portable to anything but
> "normal memory":
>
>    It is IMPLEMENTATION DEFINED whether LDREX and STREX operations can
>    be performed to a memory region with the Device or Strongly-ordered
>    memory attribute. Unless the implementation documentation explicitly
>    states that LDREX and STREX operations to a memory region with the
>    Device or Strongly-ordered attribute are permitted, the effect of
>    such operations is UNPREDICTABLE.
>
> pgprot_noncached() gives strongly-ordered memory, and so is unsuitable
> to place semaphores in for all ARMv7 implementations.
>
> Also:
>
> +       if (memtype)
> +               va = ioremap(start, size);
>
> this returns *device* memory, which is also unsuitable for all ARMv7
> implementations.
>
> It seems that pstore is playing in areas of the architecture which are
> implementation defined, so it's no surprise that folk are seeing
> different behaviours with different implementations.
>
> The code isn't architecturally wrong, it just isn't portable to all ARMv7
> implementations.
>
> So, saying that it works on some ARMv7 implementations is irrelevent.
>
> Note that LDREX and STREX are used for all operations that require
> atomicity - iow, atomics and locks.
>
> pgprot_writecombine() and ioremap_wc() will return memory which is
> suitable for these exclusive accesses - it maps to the architectures'
> "normal memory, uncacheable".
>

Unfortunately, pgprot_writecombine() doesn't work in my case (for
rk3288 and rk3399). It was also reported not to work on Tegra Logan by
Nvidia. As mentioned earlier, PAGE_KERNEL works, at least for rk3288
and rk3399.

Guenter

> So, I suspect the OP should not be using mem_type=1 or using the
> "unbuffered" DT attribute, but should leave it was the default
> (mem_type=0).
>
>
> --
> RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
> according to speedtest.net.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Problem with atomic accesses in pstore on some ARM CPUs Guenter Roeck <groeck@google.com> - 2016-08-16 01:20 +0200
  Re: Problem with atomic accesses in pstore on some ARM CPUs Robin Murphy <robin.murphy@arm.com> - 2016-08-16 12:40 +0200
    Re: Problem with atomic accesses in pstore on some ARM CPUs Will Deacon <will.deacon@arm.com> - 2016-08-16 12:50 +0200
      Re: Problem with atomic accesses in pstore on some ARM CPUs Guenter Roeck <groeck@google.com> - 2016-08-16 15:30 +0200
    Re: Problem with atomic accesses in pstore on some ARM CPUs Guenter Roeck <groeck@google.com> - 2016-08-16 15:20 +0200
      Re: Problem with atomic accesses in pstore on some ARM CPUs Will Deacon <will.deacon@arm.com> - 2016-08-16 15:30 +0200
        Re: Problem with atomic accesses in pstore on some ARM CPUs Guenter Roeck <groeck@google.com> - 2016-08-16 17:20 +0200
          Re: Problem with atomic accesses in pstore on some ARM CPUs Mark Rutland <mark.rutland@arm.com> - 2016-08-16 19:30 +0200
            Re: Problem with atomic accesses in pstore on some ARM CPUs Colin Cross <ccross@android.com> - 2016-08-16 19:50 +0200
              Re: Problem with atomic accesses in pstore on some ARM CPUs Guenter Roeck <groeck@google.com> - 2016-08-16 22:30 +0200
                Re: Problem with atomic accesses in pstore on some ARM CPUs Kees Cook <keescook@chromium.org> - 2016-08-16 23:00 +0200
                Re: Problem with atomic accesses in pstore on some ARM CPUs Guenter Roeck <groeck@google.com> - 2016-08-17 02:30 +0200
              Re: Problem with atomic accesses in pstore on some ARM CPUs Russell King - ARM Linux <linux@armlinux.org.uk> - 2016-08-19 11:40 +0200
                Re: Problem with atomic accesses in pstore on some ARM CPUs Guenter Roeck <groeck@google.com> - 2016-08-19 14:50 +0200
            Re: Problem with atomic accesses in pstore on some ARM CPUs Arnd Bergmann <arnd@arndb.de> - 2016-08-22 23:10 +0200

csiph-web