kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: "Matwey V. Kornilov" <matwey.kornilov@gmail.com>, kvm@vger.kernel.org
Cc: iommu <iommu@lists.linux-foundation.org>
Subject: Re: IOMMU, DMA and legacy PCI board
Date: Fri, 15 Jan 2016 09:14:27 -0700	[thread overview]
Message-ID: <1452874467.14628.129.camel@redhat.com> (raw)
In-Reply-To: <n7b3vt$ra8$1@ger.gmane.org>

On Fri, 2016-01-15 at 18:41 +0300, Matwey V. Kornilov wrote:
> Hello,
> 
> I am sorry, if I am asking this in a wrong place. I have an legacy
> custom PCI board, which requires contiguous DMA memory region (about 4
> MB) and does not support scatter/gather.
> 
> As contiguous DMA region cannot be allocated with the guaranty,
> currently, the issue is solved by using mem= kernel command line
> argument and using 'hidden memory' within first 3GB of RAM.
> 
> Happily, I have the kernel module source codes.
> I am not quite familiar with the internals of IOMMU. The question is the
> following. Is it possible to use IOMMU to emulate contiguous DMA region
> consisted of smaller chunks on the other side?
> If it is possible in theory, how could my PCI device driver use existing
> kernel API to implement this?


Your question is really better directed to the iommu list (cc'd) since
you don't appear to be doing anything KVM related.  It sounds like what
you want is the contiguous memory allocator (cma), see:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/dma-contiguous.h

I believe if you specify the size of the available cma using the cma=
boot option then the driver can use the standard DMA API
dma_alloc_coherent().  If you want to be more in control of the address
space for the device you can use the IOMMU API which would give you
control to dynamically add buffers to a contiguous address space for
your device.  cma does not require an iommu, the IOMMU API does.
Thanks,

Alex

      reply	other threads:[~2016-01-15 16:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-15 15:41 IOMMU, DMA and legacy PCI board Matwey V. Kornilov
2016-01-15 16:14 ` Alex Williamson [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=1452874467.14628.129.camel@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kvm@vger.kernel.org \
    --cc=matwey.kornilov@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).