2001-10-04 00:29:50

by David Mosberger

[permalink] [raw]
Subject: ioremap() vs. ioremap_nocache()

Jes Sorensen was kind enough to point out a longstanding
mis-conception that I had about ioremap(): I thought that ioremap()
was being deprecated in favor of ioremap_nocache() because the former
does not clearly define what kind of memory attribute will be used to
access the mapped memory (cached, write-through cached,
write-coalescing, etc). But I seem to have been wrong about that.
Now, as far as I know, on x86, ioremap() will give write-through
cached mappings (in the absence of mtrr games). If this is true, how
can this work? There are many drivers out there that use ioremap() on
memory mapped I/O regions that do NOT have the "Prefetchable" bit set
in the PCI BAR. For example, the eepro100 driver does this and it has
a routine called wait_for_cmd_done(), which spins on an ioremapped
read. On an x86, what prevents these reads from being cached?

Thanks,

--david


2001-10-04 20:42:31

by Alan

[permalink] [raw]
Subject: Re: ioremap() vs. ioremap_nocache()

> Now, as far as I know, on x86, ioremap() will give write-through
> cached mappings (in the absence of mtrr games). If this is true, how

On x86 ioremap will give mappings appropriate to the object you map - which
means by default it wil give uncached mappings. The PCI hardware will do
intelligent things in certain cases such as write merging

Alan

2001-10-05 14:12:57

by Jes Sorensen

[permalink] [raw]
Subject: Re: ioremap() vs. ioremap_nocache()

>>>>> "Alan" == Alan Cox <[email protected]> writes:

>> Now, as far as I know, on x86, ioremap() will give write-through
>> cached mappings (in the absence of mtrr games). If this is true,
>> how

Alan> On x86 ioremap will give mappings appropriate to the object you
Alan> map - which means by default it wil give uncached mappings. The
Alan> PCI hardware will do intelligent things in certain cases such as
Alan> write merging

Are you thereby saying that ioremap() and ioremap_nocache() are
identical on the x86?

Cheers,
Jes

2001-10-05 14:34:53

by Alan

[permalink] [raw]
Subject: Re: ioremap() vs. ioremap_nocache()

> Alan> On x86 ioremap will give mappings appropriate to the object you
> Alan> map - which means by default it wil give uncached mappings. The
> Alan> PCI hardware will do intelligent things in certain cases such as
> Alan> write merging
>
> Are you thereby saying that ioremap() and ioremap_nocache() are
> identical on the x86?

In certain peculiar cases - no. Think about an ioremap of an object mapped
onto the system bus as RAM.

2001-10-05 16:08:42

by David Mosberger

[permalink] [raw]
Subject: Re: ioremap() vs. ioremap_nocache()

>>>>> On Fri, 5 Oct 2001 16:51:45 +0100 (BST), Alan Cox <[email protected]> said:

>> >>>>> On Fri, 5 Oct 2001 12:18:07 +0100 (BST), Alan Cox
>> <[email protected]> said:
>>
>> Can you tell me what the answer is to this question?

>> When is a programmer supposed to use ioremap()
>> vs. ioremap_nocache().

Alan> You should never need ioremap_nocache for anything
Alan> non-ultraweird.

Then who added it and why?

--david