From: Clemens Ladisch <clemens@ladisch.de>
To: MJ embd <mj.embd@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: equivalent of phys_to_virt in an iommu system
Date: Fri, 28 Jan 2011 10:32:59 +0100 [thread overview]
Message-ID: <4D428D4B.1000307@ladisch.de> (raw)
In-Reply-To: <AANLkTi=+Hx+3Jk0yprAffhvQM+WcO+WytaLBU-vwbetc@mail.gmail.com>
MJ embd wrote:
> Assuming at core mmu there is a mapping, V1 -> P1
Note: It's possible that there are pages for which there is no
mapping, e.g., highmem pages; and it's possible for a page to
have multiple mappings.
> And at the IOMMU for the device to access a region of DDR there is a
> mapping P2 -> P1. [P2 is the address on which device issues a r/w]
P2 is an address on a different bus, in a different address space,
so it might be a better idea to call it D1.
> Now the device driver does the following.
>
> Line 0: V1 = kmalloc();
> Line 1: P2 = dma_map_single(V1)
>
> Now if later in the driver, there is a requirement to get V1 from P2
> what is the primitive in linux ?
V1;
That is, save the address in a variable. :-)
The DMA mapping functions typically do not save the original virtual
address, and there is no API for the reverse mapping.
If you device gives you some status message with nothing but P2, you
have to use some other mechanism to find the original virtual address.
This depends on how you device's DMA is organized; often, it is
possible to store the pointer near the DMA descriptor, or the device
has a offset relative to the known start of the buffer.
> Also is my understanding of Line 1(above) correct ?
Yes; P2 is the address that the device must use on _its_ bus.
Regards,
Clemens
prev parent reply other threads:[~2011-01-28 9:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-28 5:14 equivalent of phys_to_virt in an iommu system MJ embd
2011-01-28 9:32 ` Clemens Ladisch [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D428D4B.1000307@ladisch.de \
--to=clemens@ladisch.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mj.embd@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.