Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.os.linux.development.system > #196
| From | Pavel Borzenkov <pavel@devio.us> |
|---|---|
| Newsgroups | comp.os.linux.development.system |
| Subject | Re: Physical address being returned as 0 in mmap |
| Date | 2011-07-04 06:25 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <slrnj12n71.30l.pavel@wolfman.devio.us> (permalink) |
| References | <b8c27cd4-10d6-4225-b2af-b6dbe1bb50fb@q15g2000yqk.googlegroups.com> |
Hi, On 2011-07-02, newton mailinglist <newtonmailinglist@gmail.com> wrote: > I have written a PCI driver for my device. The device is an FPGA which > is configured with a design that allows it to have direct access to > memory of a host computer to which the fpga board is connected. My > device driver is responsible for translating virtual addresses to > physical addresses and sending these to the FPGA so the DMA unit in > the FPGA can directly access pages in memory using the physical > address. [ skipped ] > When the driver gets the above call then I assume the kernel has > already allocated the required space and its details are in the vma > parameter. When I try to view the physical address of the virtual > address in the vma i use : > > virt_to_phys(vma->vm_start) You can't use virt_to_phys for dynamically allocated memory. This macro can be used only for directly mapped kernel memory, aka kernel logical memory. What you need to do is to allocate the required amount of memory using dma_alloc_coherent() function and then map this memory into userspace process' address space using, for example, remap_pfn_range() function. dma_alloc_coherent() function returns both kernel virtual and physical addresses. You can send this physical address to FPGA. -- Pavel
Back to comp.os.linux.development.system | Previous | Next — Previous in thread | Find similar
Physical address being returned as 0 in mmap newton mailinglist <newtonmailinglist@gmail.com> - 2011-07-01 17:02 -0700 Re: Physical address being returned as 0 in mmap Pavel Borzenkov <pavel@devio.us> - 2011-07-04 06:25 +0000
csiph-web