From: Thierry Reding <thierry.reding@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Alexandre Courbot <gnurou@gmail.com>
Subject: [PATCH 6/8] drm/cache: Implement drm_clflush_*() for ARM
Date: Tue, 16 Dec 2014 17:15:13 +0100 [thread overview]
Message-ID: <1418746515-24773-7-git-send-email-thierry.reding@gmail.com> (raw)
In-Reply-To: <1418746515-24773-1-git-send-email-thierry.reding@gmail.com>
From: Thierry Reding <treding@nvidia.com>
Add implementations for drm_clflush_*() on ARM by borrowing code from
the DMA mapping API implementation. Unfortunately ARM doesn't export an
API to flush caches on a page by page basis, so this replicates most of
the code.
Reviewed--by: Rob Clark <robdclark@gmail.com>
Tested-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/drm_cache.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
index a6b690626a6b..fca0b8994c77 100644
--- a/drivers/gpu/drm/drm_cache.c
+++ b/drivers/gpu/drm/drm_cache.c
@@ -72,6 +72,41 @@ drm_clflush_ipi_handler(void *null)
}
#endif
+#if defined(CONFIG_ARM)
+
+#include <asm/cacheflush.h>
+#include <asm/cachetype.h>
+#include <asm/highmem.h>
+#include <asm/outercache.h>
+
+static void drm_clflush_page(struct page *page)
+{
+ enum dma_data_direction dir = DMA_TO_DEVICE;
+ phys_addr_t phys = page_to_phys(page);
+ size_t size = PAGE_SIZE;
+ void *virt;
+
+ if (PageHighMem(page)) {
+ if (cache_is_vipt_nonaliasing()) {
+ virt = kmap_atomic(page);
+ dmac_map_area(virt, size, dir);
+ kunmap_atomic(virt);
+ } else {
+ virt = kmap_high_get(page);
+ if (virt) {
+ dmac_map_area(virt, size, dir);
+ kunmap_high(page);
+ }
+ }
+ } else {
+ virt = page_address(page);
+ dmac_map_area(virt, size, dir);
+ }
+
+ outer_flush_range(phys, phys + PAGE_SIZE);
+}
+#endif
+
void
drm_clflush_pages(struct page *pages[], unsigned long num_pages)
{
@@ -99,6 +134,11 @@ drm_clflush_pages(struct page *pages[], unsigned long num_pages)
(unsigned long)page_virtual + PAGE_SIZE);
kunmap_atomic(page_virtual);
}
+#elif defined(CONFIG_ARM)
+ unsigned long i;
+
+ for (i = 0; i < num_pages; i++)
+ drm_clflush_page(pages[i]);
#else
printk(KERN_ERR "Architecture has no drm_cache.c support\n");
WARN_ON_ONCE(1);
@@ -123,6 +163,11 @@ drm_clflush_sg(struct sg_table *st)
if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
printk(KERN_ERR "Timed out waiting for cache flush.\n");
+#elif defined(CONFIG_ARM)
+ struct sg_page_iter sg_iter;
+
+ for_each_sg_page(st->sgl, &sg_iter, st->nents, 0)
+ drm_clflush_page(sg_page_iter_page(&sg_iter));
#else
printk(KERN_ERR "Architecture has no drm_cache.c support\n");
WARN_ON_ONCE(1);
--
2.1.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-12-16 16:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 16:15 [PATCH 0/8] drm/tegra: Fixes for v3.19-rc1 Thierry Reding
2014-12-16 16:15 ` [PATCH 1/8] drm/irq: Add drm_crtc_send_vblank_event() Thierry Reding
2014-12-16 16:15 ` [PATCH 2/8] drm/irq: Add drm_crtc_handle_vblank() Thierry Reding
2014-12-16 16:15 ` [PATCH 3/8] drm/irq: Add drm_crtc_vblank_count() Thierry Reding
2014-12-16 21:03 ` Daniel Vetter
2014-12-16 16:15 ` [PATCH 4/8] drm/tegra: dc: Consistently use the same pipe Thierry Reding
2014-12-16 16:15 ` [PATCH 5/8] drm/tegra: dc: Fix a potential race on page-flip completion Thierry Reding
2014-12-18 13:45 ` Alexandre Courbot
2014-12-16 16:15 ` Thierry Reding [this message]
2014-12-16 16:15 ` [PATCH 7/8] drm/tegra: gem: Flush buffer objects upon allocation Thierry Reding
2014-12-16 16:15 ` [PATCH 8/8] drm/tegra: gem: Use the proper size for GEM objects Thierry Reding
2014-12-16 18:38 ` [PATCH 0/8] drm/tegra: Fixes for v3.19-rc1 Sean Paul
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=1418746515-24773-7-git-send-email-thierry.reding@gmail.com \
--to=thierry.reding@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gnurou@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