All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hellstrom <thellstrom@vmware.com>
To: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	James Simmons <jsimmons@infradead.org>,
	Jerome Glisse <j.glisse@gmail.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [RFC] Future TTM DMA direction
Date: Mon, 09 Jan 2012 10:37:28 +0100	[thread overview]
Message-ID: <4F0AB558.3050902@vmware.com> (raw)

Hi!

When TTM was originally written, it was assumed that GPU apertures could 
address pages directly, and that the CPU could access those pages 
without explicit synchronization. The process of binding a page to a GPU 
translation table was a simple one-step operation, and we needed to 
worry about fragmentation in the GPU aperture only.

Now that we "sort of" support DMA memory there are three things I think 
are missing:

1) We can't gracefully handle coherent DMA OOMs or coherent DMA 
(Including CMA) memory fragmentation leading to failed allocations.
2) We can't handle dynamic mapping of pages into and out of dma, and 
corresponding IOMMU space shortage or fragmentation, and CPU 
synchronization.
3) We have no straightforward way of moving pages between devices.

I think a reasonable way to support this is to make binding to a 
non-fixed (system page based) TTM memory type a two-step binding 
process, so that a TTM placement consists of (DMA_TYPE, MEMORY_TYPE) 
instead of only (MEMORY_TYPE).

In step 1) the bo is bound to a specific DMA type. These could be for 
example:
(NONE, DYNAMIC, COHERENT, CMA), .... device dependent types could be 
allowed as well.
In this step, we perform dma_sync_for_device, or allocate dma-specific 
pages maintaining LRU lists so that if we receive a DMA memory 
allocation OOM, we can unbind bo:s bound to the same DMA type. Standard 
graphics cards would then, for example, use the NONE DMA type when run 
on bare metal or COHERENT when run on Xen. A "COHERENT" OOM condition 
would then lead to eviction of another bo. (Note that DMA eviction might 
involve data copies and be costly, but still better than failing).
Binding with the DYNAMIC memory type would mean that CPU accesses are 
disallowed, and that user-space CPU page mappings might need to be 
killed, with a corresponding sync_for_cpu if they are faulted in again 
(perhaps on a page-by-page basis). Any attempt to bo_kmap() a bo page 
bound to DYNAMIC DMA mapping should trigger a BUG.

In step 2) The bo is bound to the GPU in the same way it's done today. 
Evicting from DMA will of course also trigger an evict from GPU, but an 
evict from GPU will not trigger a DMA evict.

Making a bo "anonymous" and thus moveable between devices would then 
mean binding it to the "NONE" DMA type.

Comments, suggestions?

/Thomas

             reply	other threads:[~2012-01-09  9:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09  9:37 Thomas Hellstrom [this message]
2012-01-09 10:11 ` [RFC] Future TTM DMA direction Daniel Vetter
2012-01-09 10:11   ` Daniel Vetter
2012-01-09 11:01   ` Thomas Hellstrom
2012-01-09 11:01     ` Thomas Hellstrom
2012-01-10  9:18     ` Daniel Vetter
2012-01-10  9:18       ` Daniel Vetter
2012-01-10 17:46   ` Jerome Glisse
2012-01-10 17:46     ` Jerome Glisse
2012-01-25 18:16     ` Thomas Hellstrom
2012-01-25 18:16       ` Thomas Hellstrom
2012-01-25 18:16       ` Thomas Hellstrom
2012-01-10 15:10 ` Konrad Rzeszutek Wilk

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=4F0AB558.3050902@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=j.glisse@gmail.com \
    --cc=jsimmons@infradead.org \
    --cc=konrad.wilk@oracle.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.