From: Alexandre Courbot <acourbot@nvidia.com>
To: Ben Skeggs <bskeggs@redhat.com>, Thierry Reding <treding@nvidia.com>
Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
gnurou@gmail.com, Alexandre Courbot <acourbot@nvidia.com>
Subject: [PATCH] drm/nouveau/vm: fix mapping of SG pages list
Date: Tue, 3 Jun 2014 22:56:28 +0900 [thread overview]
Message-ID: <1401803788-21494-1-git-send-email-acourbot@nvidia.com> (raw)
SG pages lists (not to be confused with scatterlists) are a list of 4KB
memory pages used to define a nouveau_mem. Mapping them to a VM that
does not use 4KB apertures resulted in each subsequent 4KB physical page
being mapped into a larger VM aperture, thus creating an incorrect,
overlapping mapping.
This patch fixes this issue by detecting when such mappings occur and by
skipping the required number of pages in the list to ensure a correct
linear mapping.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
Ben, how does this look? This issue has been highlighted by the GK20A
RAM driver which makes use of nouveau_mem::pages to provide system
memory. The mapping overlap resulted in rendering issues for buffers
that were bigger than 1 big VM page.
I believe this is the correct way to fix this, and this way of building
nouveau_mem instances is not much used in the driver anyway, but you
know better. :)
drivers/gpu/drm/nouveau/core/subdev/vm/base.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
index 7dd680f..db35e8d 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
@@ -152,13 +152,18 @@ nouveau_vm_map_sg(struct nouveau_vma *vma, u64 delta, u64 length,
end = (pte + num);
if (unlikely(end >= max))
end = max;
- len = end - pte;
+
+ /*
+ * Map pages >4KB one by one so we can fix the list pointer
+ * as to not map intermediate pages to the next PTE
+ */
+ len = bits ? 1 : end - pte;
vmm->map_sg(vma, pgt, mem, pte, len, list);
num -= len;
pte += len;
- list += len;
+ list += len << bits;
if (unlikely(end >= max)) {
pde++;
pte = 0;
--
2.0.0
reply other threads:[~2014-06-03 13:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1401803788-21494-1-git-send-email-acourbot@nvidia.com \
--to=acourbot@nvidia.com \
--cc=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gnurou@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=treding@nvidia.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
all inboxes | Powered by JetHome®