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>,
	"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>
Subject: Usage of dma-buf sg-tables
Date: Fri, 01 Nov 2013 14:33:02 +0100	[thread overview]
Message-ID: <5273AD8E.7040004@vmware.com> (raw)

Hi!

Considering that the linux DMA-API states that information in an sg-list 
may be destroyed when it's mapped,
it seems to me that at least  one of the drm prime functions use invalid 
assumptions.

In particular, I don't think it's safe to assume that pages in a single 
sg-list segment are contigous after mapping, so
if we want struct page pointers we should use

pfn = dma_to_phys((sg_dma_address(sg) + p_offset*PAGE_SIZE)) >> PAGE_SHIFT

and if the pfn is valid, convert it to a struct page.

(Incorrect code is, for example, in drm_prime_sg_to_page_addr_arrays)

Or does dma-buf require that page info in sg-lists need to be kept 
across the map operation?

BTW this brings up another question: It's stated that the above function 
is needed by the TTM driver in order to do
correct fault handling. This seems odd, TTM shouldn't be able to mmap() 
or fault an imported dma-buf, right?

Thanks,
Thomas

             reply	other threads:[~2013-11-01 13:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-01 13:33 Thomas Hellstrom [this message]
2013-11-01 19:58 ` Usage of dma-buf sg-tables Daniel Vetter

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=5273AD8E.7040004@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    /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.