dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Alexandre Courbot <gnurou@gmail.com>,
	Thomas Hellstrom <thellstrom@vmware.com>,
	Allen Martin <amartin@nvidia.com>, Arnd Bergmann <arnd@arndb.de>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [RFC] drm/ttm: dma: Fixes for 32-bit and 64-bit ARM
Date: Wed, 12 Nov 2014 13:39:05 +0100	[thread overview]
Message-ID: <1415795945-17575-1-git-send-email-thierry.reding@gmail.com> (raw)

From: Thierry Reding <treding@nvidia.com>

dma_alloc_coherent() returns a kernel virtual address that is part of
the linear range. Passing such an address to virt_to_page() is illegal
on non-coherent architectures. This causes the kernel to oops on 64-bit
ARM because the struct page * obtained from virt_to_page() points to
unmapped memory.

This commit fixes this by using phys_to_page() since we get a physical
address from dma_alloc_coherent(). Note that this is not a proper fix
because if an IOMMU is set up to translate addresses for the GPU this
address will be an I/O virtual address rather than a physical one. The
proper fix probably involves not getting a pointer to the struct page
in the first place, but that would be a much more intrusive change, if
at all possible.

Until that time, this temporary fix will allow TTM to work on 32-bit
and 64-bit ARM as well, provided that no IOMMU translations are enabled
for the GPU.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Arnd, I realize that this isn't a proper fix according to what we discussed on
IRC yesterday, but I can't see a way to remove access to the pages array that
would be as simple as this. I've marked this as RFC in the hope that it will
trigger some discussion that will lead to a proper solution.

 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index c96db433f8af..d7993985752c 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -343,7 +343,11 @@ static struct dma_page *__ttm_dma_alloc_page(struct dma_pool *pool)
 					   &d_page->dma,
 					   pool->gfp_flags);
 	if (d_page->vaddr)
+#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+		d_page->p = phys_to_page(d_page->dma);
+#else
 		d_page->p = virt_to_page(d_page->vaddr);
+#endif
 	else {
 		kfree(d_page);
 		d_page = NULL;
-- 
2.1.3

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

             reply	other threads:[~2014-11-12 12:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 12:39 Thierry Reding [this message]
2014-11-12 14:18 ` [RFC] drm/ttm: dma: Fixes for 32-bit and 64-bit ARM Konrad Rzeszutek Wilk
2014-11-12 17:03   ` Arnd Bergmann
2014-12-01 16:43     ` Konrad Rzeszutek Wilk
2014-12-08  7:14 ` Alexandre Courbot
2014-12-08  7:36   ` Alexandre Courbot
2014-12-08  8:11   ` Alexandre Courbot
2014-12-08  8:19     ` Alexandre Courbot
2014-12-15  8:04   ` Alexandre Courbot

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=1415795945-17575-1-git-send-email-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=amartin@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gnurou@gmail.com \
    --cc=konrad.wilk@oracle.com \
    --cc=thellstrom@vmware.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