3

I want to create some memory to use for DMA transfers. (Using Linux 2.6.18-128.el5 #1 SMP)

I have a API stack+kernel driver for my H/W that can do this for me, but its very very slow!

If I use the API to create a DMA transfer, it allocates some memory very high up in System RAM (eg 0x7373a6f8 on one run). (I have the ICD of the device, so have a memory map mmap'd over, this is how I can find this address out, and how in the end I want to SET to my own address, and hence the /dev/mem in the maps below)

I cannot seem to be able to mmap memory around this high address, presumably as its out of my virtual memory space and im being blocked by the kernel?

What I want to be able to do is either use (map) this address given, so I can read/write to it, OR create my own physical memory that I can read/write to.

# cat /proc/iomem
00000000-0009fbff : System RAM
  00000000-00000000 : Crash kernel
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-7fd64fff : System RAM        # Is this all of /dev/mem?
  00400000-00612916 : Kernel code
  00612917-006ef9db : Kernel data

# cat /proc/3450/maps
08207000-08228000 rw-p 08207000 00:00 0          [heap]
b7e7b000-b7f85000 rw-p b7e7b000 00:00 0
b7f89000-b7f8a000 rw-p b7f89000 00:00 0
b7f8a000-b7f8b000 rw-s 80114000 00:11 1541       /dev/mem
b7f8b000-b7f8d000 rw-p b7f8b000 00:00 0
bff70000-bff85000 rw-p bffea000 00:00 0          [stack]
Ian Vaughan
  • 20,211
  • 13
  • 59
  • 79
  • If I'm understanding you correctly, you have a device driver that's behaving poorly, and you're trying to work around that by manually allocating physical RAM from userspace? Is there a reason you're not interested in fixing the driver instead? This sounds like a very odd request, not something that would be considered a proper fix by most people. I suspect you'd get more help if you were working on the underlying driver problem. – Eric Seppanen Feb 23 '10 at 20:32
  • 1
    Your right, the user space API/library is sllooow. Although I am an experienced C/C++ dev, I have not done device driers before, and it is now my or my companies domain. I was after/hoping for a quick (read dirty) hack to get round this as you worked out, but really it is now down to our API/kernel driver supplier to provide us with a better driver! Thanks for your response! – Ian Vaughan Feb 24 '10 at 22:46
  • @Eric If you want to put these words as a answer I will accept it, as although we are not using DMA now, I am implementing our own Device Driver (http://stackoverflow.com/q/5185397/119790) – Ian Vaughan Mar 07 '11 at 10:10

1 Answers1

0

If I'm understanding you correctly, you have a device driver that's behaving poorly, and you're trying to work around that by manually allocating physical RAM from userspace? Is there a reason you're not interested in fixing the driver instead?

This sounds like a very odd request, not something that would be considered a proper fix by most people. I suspect you'd get more help if you were working on the underlying driver problem.

(copied from comment above.)

Eric Seppanen
  • 5,923
  • 30
  • 24
  • 1
    I stated I'd accept this previously made comment (see above) so I have, as it is now what I have done! But I do have to have a small moan about the view-point expressed, albeit correct, it doesnt detract from not-actually-helping-answer-the-question! Many thanks though as always to every/anyones inputs... – Ian Vaughan Mar 09 '11 at 14:16
  • A fair criticism; maybe I should've made it a comment instead of an answer :) – Eric Seppanen Mar 09 '11 at 20:53