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


Groups > linux.kernel > #1340568 > unrolled thread

Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings

Started byRussell King - ARM Linux <linux@arm.linux.org.uk>
First post2016-02-23 13:00 +0100
Last post2016-02-25 08:50 +0100
Articles 6 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB  mappings Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-02-23 13:00 +0100
    Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-02-23 13:10 +0100
      Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-02-23 13:30 +0100
        Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings Dan Williams <dan.j.williams@intel.com> - 2016-02-23 18:30 +0100
          Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings Robert Jarzmik <robert.jarzmik@free.fr> - 2016-02-23 23:30 +0100
            Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-02-25 08:50 +0100

#1340568 — Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings

FromRussell King - ARM Linux <linux@arm.linux.org.uk>
Date2016-02-23 13:00 +0100
SubjectRe: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings
Message-ID<r5jNg-4Qc-19@gated-at.bofh.it>
On Mon, Feb 22, 2016 at 09:35:24PM +0100, Ard Biesheuvel wrote:
> OK, thanks for the historical context.
> 
> So what is your opinion on this series, i.e., to wire up memremap() to
> remap arbitrary memory regions into the vmalloc area with MT_MEMORY_RW
> attributes, and at the same time lift the restriction that the region
> must be disjoint from memory covered by lowmem or kmap?

The historical context is still present, because pxa2xx-flash has
been converted to use memremap() from ioremap_cache() - possibly
inappropriately.

I've already described the semantics of ioremap_cache(), which are
to always create a cacheable mapping irrespective of the system
memory mapping type.  However, memremap() says that MEMREMAP_WB
matches system RAM, which on ARM it doesn't right now.

Changing it to MT_MEMORY_RW would satisfy that comment against
memremap(), but at the same time changes what happens with
pxa2xx-flash - the memory region (which is not system RAM) then
changes with the cache status of system RAM.

So, I'm not that happy about the memremap() stuff right now, and
I don't like the idea of making memremap() conform to its stated
requirements without first preventing pxa2xx-flash being affected
by such a change.

Perhaps we need to reinstate the original ioremap_cached() API for
pxa2xx-flash, and then switch memremap() to MT_MEMORY_RW - that
would seem to result in the expected behaviour by all parties.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

[toc] | [next] | [standalone]


#1340572 — Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-02-23 13:10 +0100
SubjectRe: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings
Message-ID<r5jWW-5br-25@gated-at.bofh.it>
In reply to#1340568
On 23 February 2016 at 12:58, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Mon, Feb 22, 2016 at 09:35:24PM +0100, Ard Biesheuvel wrote:
>> OK, thanks for the historical context.
>>
>> So what is your opinion on this series, i.e., to wire up memremap() to
>> remap arbitrary memory regions into the vmalloc area with MT_MEMORY_RW
>> attributes, and at the same time lift the restriction that the region
>> must be disjoint from memory covered by lowmem or kmap?
>
> The historical context is still present, because pxa2xx-flash has
> been converted to use memremap() from ioremap_cache() - possibly
> inappropriately.
>
> I've already described the semantics of ioremap_cache(), which are
> to always create a cacheable mapping irrespective of the system
> memory mapping type.  However, memremap() says that MEMREMAP_WB
> matches system RAM, which on ARM it doesn't right now.
>

Indeed. Hence this series, to decouple memremap(MEMREMAP_WB) from
ioremap_cache() for ARM

> Changing it to MT_MEMORY_RW would satisfy that comment against
> memremap(), but at the same time changes what happens with
> pxa2xx-flash - the memory region (which is not system RAM) then
> changes with the cache status of system RAM.
>
> So, I'm not that happy about the memremap() stuff right now, and
> I don't like the idea of making memremap() conform to its stated
> requirements without first preventing pxa2xx-flash being affected
> by such a change.
>

Actually, my change fixes this issue, since it will cause memremap()
to always create MT_MEMORY_RW mappings, and not fallback to
ioremap_cache() for ranges that are not covered by lowmem.

> Perhaps we need to reinstate the original ioremap_cached() API for
> pxa2xx-flash, and then switch memremap() to MT_MEMORY_RW - that
> would seem to result in the expected behaviour by all parties.
>

I think we can simply revert the change to pxa2xx-flash if it is
deemed inappropriate.

[toc] | [prev] | [next] | [standalone]


#1340582 — Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-02-23 13:30 +0100
SubjectRe: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings
Message-ID<r5kgi-5mq-5@gated-at.bofh.it>
In reply to#1340572
On 23 February 2016 at 13:03, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> On 23 February 2016 at 12:58, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
>> On Mon, Feb 22, 2016 at 09:35:24PM +0100, Ard Biesheuvel wrote:
>>> OK, thanks for the historical context.
>>>
>>> So what is your opinion on this series, i.e., to wire up memremap() to
>>> remap arbitrary memory regions into the vmalloc area with MT_MEMORY_RW
>>> attributes, and at the same time lift the restriction that the region
>>> must be disjoint from memory covered by lowmem or kmap?
>>
>> The historical context is still present, because pxa2xx-flash has
>> been converted to use memremap() from ioremap_cache() - possibly
>> inappropriately.
>>
>> I've already described the semantics of ioremap_cache(), which are
>> to always create a cacheable mapping irrespective of the system
>> memory mapping type.  However, memremap() says that MEMREMAP_WB
>> matches system RAM, which on ARM it doesn't right now.
>>
>
> Indeed. Hence this series, to decouple memremap(MEMREMAP_WB) from
> ioremap_cache() for ARM
>
>> Changing it to MT_MEMORY_RW would satisfy that comment against
>> memremap(), but at the same time changes what happens with
>> pxa2xx-flash - the memory region (which is not system RAM) then
>> changes with the cache status of system RAM.
>>
>> So, I'm not that happy about the memremap() stuff right now, and
>> I don't like the idea of making memremap() conform to its stated
>> requirements without first preventing pxa2xx-flash being affected
>> by such a change.
>>
>
> Actually, my change fixes this issue, since it will cause memremap()
> to always create MT_MEMORY_RW mappings, and not fallback to
> ioremap_cache() for ranges that are not covered by lowmem.
>
>> Perhaps we need to reinstate the original ioremap_cached() API for
>> pxa2xx-flash, and then switch memremap() to MT_MEMORY_RW - that
>> would seem to result in the expected behaviour by all parties.
>>
>
> I think we can simply revert the change to pxa2xx-flash if it is
> deemed inappropriate.

OK, I see what you mean. I find it unfortunate that ioremap_cache()
instances are blindly being replaced with memremap(), and I wonder if
this wasted test by and/or cc'ed to people who can actually test this
driver. Dan?

Anyway, I don't think it makes sense to stipulate at the generic level
that ioremap_cache() and memremap(MEMREMAP_WB) shall be the same, and
deprecating it is a bit premature since the cross-architecturally
loosely defined semantics of ioremap_cache() can never be replaced 1:1
with what memremap() promises.

So what I suggest is that I revert the change to pxa2xx-flash as a new
1/3 in this series, and put these existing two on top to decouple
memremap(MEMREMAP_WB) from ioremap_cache() entirely.

Thanks,
Ard.

[toc] | [prev] | [next] | [standalone]


#1340894 — Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings

FromDan Williams <dan.j.williams@intel.com>
Date2016-02-23 18:30 +0100
SubjectRe: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings
Message-ID<r5oWC-8P-21@gated-at.bofh.it>
In reply to#1340582
On Tue, Feb 23, 2016 at 4:26 AM, Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
> On 23 February 2016 at 13:03, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>> On 23 February 2016 at 12:58, Russell King - ARM Linux
>> <linux@arm.linux.org.uk> wrote:
>>> On Mon, Feb 22, 2016 at 09:35:24PM +0100, Ard Biesheuvel wrote:
>>>> OK, thanks for the historical context.
>>>>
>>>> So what is your opinion on this series, i.e., to wire up memremap() to
>>>> remap arbitrary memory regions into the vmalloc area with MT_MEMORY_RW
>>>> attributes, and at the same time lift the restriction that the region
>>>> must be disjoint from memory covered by lowmem or kmap?
>>>
>>> The historical context is still present, because pxa2xx-flash has
>>> been converted to use memremap() from ioremap_cache() - possibly
>>> inappropriately.
>>>
>>> I've already described the semantics of ioremap_cache(), which are
>>> to always create a cacheable mapping irrespective of the system
>>> memory mapping type.  However, memremap() says that MEMREMAP_WB
>>> matches system RAM, which on ARM it doesn't right now.
>>>
>>
>> Indeed. Hence this series, to decouple memremap(MEMREMAP_WB) from
>> ioremap_cache() for ARM
>>
>>> Changing it to MT_MEMORY_RW would satisfy that comment against
>>> memremap(), but at the same time changes what happens with
>>> pxa2xx-flash - the memory region (which is not system RAM) then
>>> changes with the cache status of system RAM.
>>>
>>> So, I'm not that happy about the memremap() stuff right now, and
>>> I don't like the idea of making memremap() conform to its stated
>>> requirements without first preventing pxa2xx-flash being affected
>>> by such a change.
>>>
>>
>> Actually, my change fixes this issue, since it will cause memremap()
>> to always create MT_MEMORY_RW mappings, and not fallback to
>> ioremap_cache() for ranges that are not covered by lowmem.
>>
>>> Perhaps we need to reinstate the original ioremap_cached() API for
>>> pxa2xx-flash, and then switch memremap() to MT_MEMORY_RW - that
>>> would seem to result in the expected behaviour by all parties.
>>>
>>
>> I think we can simply revert the change to pxa2xx-flash if it is
>> deemed inappropriate.
>
> OK, I see what you mean. I find it unfortunate that ioremap_cache()
> instances are blindly being replaced with memremap(), and I wonder if
> this wasted test by and/or cc'ed to people who can actually test this
> driver. Dan?

I included that change in my original "convert ARM to memremap"
patchset [1].  I admit I didn't see the problem initially, but in
hindsight I should have told Brian to hold off until the whole
approach was sanity checked by ARM core maintainers.  Since then I've
been deferring the deprecation of ioremap_cache() until we could have
a conversation like this one.

> Anyway, I don't think it makes sense to stipulate at the generic level
> that ioremap_cache() and memremap(MEMREMAP_WB) shall be the same, and
> deprecating it is a bit premature since the cross-architecturally
> loosely defined semantics of ioremap_cache() can never be replaced 1:1
> with what memremap() promises.

Ok, my goal was to clean all the cases the were mishandling the
__iomem annotation where the *accesses* did not have I/O side effects.
What I overlooked was the difference between varying flavors of
writeback cacheable mappings.

> So what I suggest is that I revert the change to pxa2xx-flash as a new
> 1/3 in this series, and put these existing two on top to decouple
> memremap(MEMREMAP_WB) from ioremap_cache() entirely.

Should we formalize the pxa2xx-flash case with a new MEMREMAP_<type>?
Part of the original confusion is that we have ioremap_cache() with
varying semantics across architectures.

[1]: http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/360888.html

[toc] | [prev] | [next] | [standalone]


#1341140 — Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2016-02-23 23:30 +0100
SubjectRe: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings
Message-ID<r5tCX-3y6-37@gated-at.bofh.it>
In reply to#1340894
Dan Williams <dan.j.williams@intel.com> writes:

> On Tue, Feb 23, 2016 at 4:26 AM, Ard Biesheuvel
> <ard.biesheuvel@linaro.org> wrote:
>> On 23 February 2016 at 13:03, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>>> On 23 February 2016 at 12:58, Russell King - ARM Linux
>>> <linux@arm.linux.org.uk> wrote:
>>>> On Mon, Feb 22, 2016 at 09:35:24PM +0100, Ard Biesheuvel wrote:
>> OK, I see what you mean. I find it unfortunate that ioremap_cache()
>> instances are blindly being replaced with memremap(), and I wonder if
>> this wasted test by and/or cc'ed to people who can actually test this
>> driver. Dan?

Actually I have the hardware to test it.

And I also know what is behind :
 - it's a CFI NOR based memory
 - these are Intel StrataFlash 28F128J3A chips
 - as a CFI memory it is mapped on the system bus
 - from a read perspective, it behaves like a normal memory
 - but once the first write reaches the CFI, everything changes (the address
   space layout doesn't have the same meaning, be that becoming a status code or
   something else).
   In these conditions reordering of writes versus reads, merging reads after
   a write or coalescing writes is a recipe for disaster.

All of this to say I can make a small discrete number of tests (less than 10
write or erase ones to preserve the precious NOR).

Cheers.

--
Robert

[toc] | [prev] | [next] | [standalone]


#1342918 — Re: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2016-02-25 08:50 +0100
SubjectRe: [RFC PATCH 1/2] memremap: add arch specific hook for MEMREMAP_WB mappings
Message-ID<r5YQs-um-31@gated-at.bofh.it>
In reply to#1341140
On 23 February 2016 at 23:23, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
> Dan Williams <dan.j.williams@intel.com> writes:
>
>> On Tue, Feb 23, 2016 at 4:26 AM, Ard Biesheuvel
>> <ard.biesheuvel@linaro.org> wrote:
>>> On 23 February 2016 at 13:03, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>>>> On 23 February 2016 at 12:58, Russell King - ARM Linux
>>>> <linux@arm.linux.org.uk> wrote:
>>>>> On Mon, Feb 22, 2016 at 09:35:24PM +0100, Ard Biesheuvel wrote:
>>> OK, I see what you mean. I find it unfortunate that ioremap_cache()
>>> instances are blindly being replaced with memremap(), and I wonder if
>>> this wasted test by and/or cc'ed to people who can actually test this
>>> driver. Dan?
>
> Actually I have the hardware to test it.
>
> And I also know what is behind :
>  - it's a CFI NOR based memory
>  - these are Intel StrataFlash 28F128J3A chips
>  - as a CFI memory it is mapped on the system bus
>  - from a read perspective, it behaves like a normal memory
>  - but once the first write reaches the CFI, everything changes (the address
>    space layout doesn't have the same meaning, be that becoming a status code or
>    something else).
>    In these conditions reordering of writes versus reads, merging reads after
>    a write or coalescing writes is a recipe for disaster.
>
> All of this to say I can make a small discrete number of tests (less than 10
> write or erase ones to preserve the precious NOR).
>

Thanks Robert.

But to be honest, I think we should simply revert the change, after
which we can wire up memremap() for ARM properly. And while I agree
that ioremap_cache() is often abused for mapping things like ACPI
tables in RAM (which forces you to cast away the __iomem annotation),
using ioremap_cache() to map NOR flash is totally different IMO, even
if it has memory semantics while in array mode.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web