Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.system > #196

Re: Physical address being returned as 0 in mmap

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Pavel Borzenkov <pavel@devio.us>
Newsgroups comp.os.linux.development.system
Subject Re: Physical address being returned as 0 in mmap
Date Mon, 4 Jul 2011 06:25:36 +0000 (UTC)
Organization Aioe.org NNTP Server
Lines 31
Message-ID <slrnj12n71.30l.pavel@wolfman.devio.us> (permalink)
References <b8c27cd4-10d6-4225-b2af-b6dbe1bb50fb@q15g2000yqk.googlegroups.com>
NNTP-Posting-Host 5Bi2vCRq6cgjQObVvr9N+Q.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent slrn/0.9.9p1 (OpenBSD)
X-Notice Filtered by postfilter v. 0.8.2
Xref x330-a1.tempe.blueboxinc.net comp.os.linux.development.system:196

Show key headers only | View raw


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 | NextPrevious in thread | Find similar


Thread

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