Skip to contentSkip to conversation

Prefered method to map PCI memory into userspace.

DISCUSSION Andi Kleen 2 participants 4 messages Sep 26, 2003 – Sep 27, 2003 4 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 5 lines · Jim Deas

I am looking for the most current (blessed) structure for mapping PCI memory to a user process. One that allows both PIO and busmastering to work on a common block of PCI RAM. I am not concerned with backporting to older kernels but it would be nice if the solution wasn't ibm specific.

mmap on /dev/mem

PIO cannot be done on memory, for that you have to use iopl() or ioperm() to get access to the port and then issue the PIO instructions yourself

The only trap with the mapping is getting uncached mappings (most PCI hardware prefers uncached accesses). When the mapping is beyond the end of memory the kernel will automatically map it uncached. PCI mappings are normally in the PCI hole at the end of the 4GB area. When you machine has more than 4GB of ram this heuristic does not work and you have set MTRRs by hand using /proc/mtrr or use O_SYNC. The later is cleanest, but only works in newer kernels.

[BTW I consider this a kernel bug - it should always map mappings to non memory uncached]

-Andi

#2 lore raw
Quoted 5 lines · On 27 Sep 2003 00:03:42 +0200 Andi Kleen <[email protected]> wrote:

mmap on /dev/mem

PIO cannot be done on memory, for that you have to use iopl() or ioperm() to get access to the port and then issue the PIO instructions yourself

Platform dependant, mmap on /dev/mem doesn't work on many systems.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#6 lore raw
Quoted 7 lines · David S. Miller

If someone is looking for something to do, it would be incredibly value to make it so that all arches support this, and in particular get right the case of mmap()'ing the PCI host bridge.

If this were done, the PCI domain code in xfree86 could be enabled for all Linux platforms, not just the ones that have this implemented properly.

What semantics would it have? Can the "seek offset" just be the bus address?

If yes then it would be trivial to implement for x86/x86-64

-andi

#7 lore raw
Quoted 6 lines · On 27 Sep 2003 07:09:01 +0200 Andi Kleen <[email protected]> wrote:
Quoted 4 lines · David S. Miller

If someone is looking for something to do, it would be incredibly value to make it so that all arches support this, and in particular get right the case of mmap()'ing the PCI host bridge.

Quoted 8 lines
Quoted 3 lines

If this were done, the PCI domain code in xfree86 could be enabled for all Linux platforms, not just the ones that have this implemented properly.

What semantics would it have? Can the "seek offset" just be the bus address?

If yes then it would be trivial to implement for x86/x86-64

I did everything for x86 already, egrep for "PCI_MMAP" under arch/i386/.

The uncompleted part is the PCI host bridge mmap() support, I just never got around to it. Someone can easily complete it.