On Mon, Mar 24, 2014 at 10:42 AM, Arnd Bergmann <[email protected]> wrote:
> On Monday 24 March 2014 08:36:46 Rob Herring wrote:
>> On Mon, Mar 24, 2014 at 6:29 AM, Arnd Bergmann <[email protected]> wrote:
>> > On Monday 24 March 2014 11:22:03 Catalin Marinas wrote:
>> >> On Fri, Mar 21, 2014 at 09:08:44PM +0000, Rob Herring wrote:
>> >> > diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
>> >> > new file mode 100644
>> >> > index 0000000..241757a
>> >> > --- /dev/null
>> >> > +++ b/drivers/tty/serial/earlycon.c
>> >> [...]
>> >> > +static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
>> >> > +{
>> >> > + void __iomem *base;
>> >> > +#ifdef CONFIG_FIX_EARLYCON_MEM
>> >> > + set_fixmap_nocache(FIX_EARLYCON_MEM_BASE, paddr & PAGE_MASK);
>> >> > + base = (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE);
>> >> > + base += paddr & ~PAGE_MASK;
>> >> > +#else
>> >> > + base = ioremap_nocache(paddr, size);
>> >> > +#endif
>> >>
>> >> Just curious why not set_fixmap_io (and plain ioremap)?
>> >
>> > Good point. Note that ioremap_nocache() is the same as ioremap()
>> > on *all* architectures.
Did you mean "not the same"? Why are there 2 flavors if they are
always the same.
>> I investigated this before adding this to arm64. set_fixmap_io and
>> set_fixmap_nocache are not the same settings on x86. Whether the
>> mapping type really matters on x86 or not, I don't know. So I added
>> the nocache variant to arm64 to avoid a change to x86.
>
> My best guess is that it's an x86 bug. ioremap() always uses an uncached
> mapping on x86, so it's strange to see early_ioremap() and set_fixmap_io()
> use a cached mapping. It probably doesn't matter as long as the mtrr is
> set up to treat all MMIO registers as non-cacheable, but I think there
> should not be a difference.
At some point it was believed to be needed on the 8250 driver. Perhaps
Alan can comment since the commit message tells us nothing:
commit 6f441fe99814f64315b8c11890744230b990c460
Author: Alan Cox <[email protected]>
Date: Thu May 1 04:34:59 2008 -0700
8250: switch 8250 drivers to use _nocache ioremaps
Signed-off-by: Alan Cox <[email protected]>
Cc: Russell King <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Rob
> At some point it was believed to be needed on the 8250 driver. Perhaps
> Alan can comment since the commit message tells us nothing:
Don't remember sorry - I guess at the time someone had ioremap on their
plaform acting as cached. It was a long time ago 8)
On Thursday 17 April 2014, Rob Herring wrote:
> On Mon, Mar 24, 2014 at 10:42 AM, Arnd Bergmann <[email protected]> wrote:
> > On Monday 24 March 2014 08:36:46 Rob Herring wrote:
> >> On Mon, Mar 24, 2014 at 6:29 AM, Arnd Bergmann <[email protected]> wrote:
> >> > On Monday 24 March 2014 11:22:03 Catalin Marinas wrote:
> >> >> On Fri, Mar 21, 2014 at 09:08:44PM +0000, Rob Herring wrote:
> >> >> > diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> >> >> > new file mode 100644
> >> >> > index 0000000..241757a
> >> >> > --- /dev/null
> >> >> > +++ b/drivers/tty/serial/earlycon.c
> >> >> [...]
> >> >> > +static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
> >> >> > +{
> >> >> > + void __iomem *base;
> >> >> > +#ifdef CONFIG_FIX_EARLYCON_MEM
> >> >> > + set_fixmap_nocache(FIX_EARLYCON_MEM_BASE, paddr & PAGE_MASK);
> >> >> > + base = (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE);
> >> >> > + base += paddr & ~PAGE_MASK;
> >> >> > +#else
> >> >> > + base = ioremap_nocache(paddr, size);
> >> >> > +#endif
> >> >>
> >> >> Just curious why not set_fixmap_io (and plain ioremap)?
> >> >
> >> > Good point. Note that ioremap_nocache() is the same as ioremap()
> >> > on *all* architectures.
>
> Did you mean "not the same"?
No
> Why are there 2 flavors if they are
> always the same.
I assume it's just a mistake someone made a long time ago and nobody
ever changed it because they didn't want to break obscure code.
x86 seems to be a bit odd here, because is has both page-table
and MTRR method of setting up whether an access can be cached or not.
This may have led to the introduction of the _nocache variant, when
the regular ioremap was already uncached on all other architectures
but cached on x86.
Arnd