All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: [PATCH 23/36] drm/omap: fix TILER on OMAP5
Date: Tue, 24 Mar 2015 14:15:40 +0200	[thread overview]
Message-ID: <1427199353-4412-24-git-send-email-tomi.valkeinen@ti.com> (raw)
In-Reply-To: <1427199353-4412-1-git-send-email-tomi.valkeinen@ti.com>

On OMAP5 it is not possible to use TILER buffer with CPU when caching or
write-combining is used. Doing so leads to errors from the memory
manager.

However, on OMAP4, write-combining works fine.

This patch adds platform specific data for the TILER, and a function
tiler_get_cpu_cache_flags() which can be used to get the caching mode to
be used.

Note that without write-combining the use of the TILER buffer with CPU
is unusably slow. It's still good to have it operational for testing
purposes.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_dmm_priv.h  |  6 +++++
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 39 ++++++++++++++++++++++++++++++--
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.h |  1 +
 drivers/gpu/drm/omapdrm/omap_gem.c       |  4 ++--
 4 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_priv.h b/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
index 58bcd6ae0255..d96660573076 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
@@ -153,6 +153,10 @@ struct refill_engine {
 	struct list_head idle_node;
 };
 
+struct dmm_platform_data {
+	uint32_t cpu_cache_flags;
+};
+
 struct dmm {
 	struct device *dev;
 	void __iomem *base;
@@ -183,6 +187,8 @@ struct dmm {
 
 	/* allocation list and lock */
 	struct list_head alloc_head;
+
+	const struct dmm_platform_data *plat_data;
 };
 
 #endif
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index b4476859c1ad..f06243b3d3c0 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -39,6 +39,10 @@
 static struct tcm *containers[TILFMT_NFORMATS];
 static struct dmm *omap_dmm;
 
+#if defined(CONFIG_OF)
+static const struct of_device_id dmm_of_match[];
+#endif
+
 /* global spinlock for protecting lists */
 static DEFINE_SPINLOCK(list_lock);
 
@@ -529,6 +533,11 @@ size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h)
 	return round_up(geom[fmt].cpp * w, PAGE_SIZE) * h;
 }
 
+uint32_t tiler_get_cpu_cache_flags(void)
+{
+	return omap_dmm->plat_data->cpu_cache_flags;
+}
+
 bool dmm_is_available(void)
 {
 	return omap_dmm ? true : false;
@@ -592,6 +601,18 @@ static int omap_dmm_probe(struct platform_device *dev)
 
 	init_waitqueue_head(&omap_dmm->engine_queue);
 
+	if (dev->dev.of_node) {
+		const struct of_device_id *match;
+
+		match = of_match_node(dmm_of_match, dev->dev.of_node);
+		if (!match) {
+			dev_err(&dev->dev, "failed to find matching device node\n");
+			return -ENODEV;
+		}
+
+		omap_dmm->plat_data = match->data;
+	}
+
 	/* lookup hwmod data - base address and irq */
 	mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!mem) {
@@ -972,9 +993,23 @@ static const struct dev_pm_ops omap_dmm_pm_ops = {
 #endif
 
 #if defined(CONFIG_OF)
+static const struct dmm_platform_data dmm_omap4_platform_data = {
+	.cpu_cache_flags = OMAP_BO_WC,
+};
+
+static const struct dmm_platform_data dmm_omap5_platform_data = {
+	.cpu_cache_flags = OMAP_BO_UNCACHED,
+};
+
 static const struct of_device_id dmm_of_match[] = {
-	{ .compatible = "ti,omap4-dmm", },
-	{ .compatible = "ti,omap5-dmm", },
+	{
+		.compatible = "ti,omap4-dmm",
+		.data = &dmm_omap4_platform_data,
+	},
+	{
+		.compatible = "ti,omap5-dmm",
+		.data = &dmm_omap5_platform_data,
+	},
 	{},
 };
 #endif
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
index 4fdd61e54bd2..e83c78372db8 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
@@ -106,6 +106,7 @@ uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient);
 size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h);
 size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h);
 void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h);
+uint32_t tiler_get_cpu_cache_flags(void);
 bool dmm_is_available(void);
 
 extern struct platform_driver omap_dmm_driver;
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 9b250c93b046..d37ee756a0b1 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -1359,8 +1359,8 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
 		/* currently don't allow cached buffers.. there is some caching
 		 * stuff that needs to be handled better
 		 */
-		flags &= ~(OMAP_BO_CACHED|OMAP_BO_UNCACHED);
-		flags |= OMAP_BO_WC;
+		flags &= ~(OMAP_BO_CACHED|OMAP_BO_WC|OMAP_BO_UNCACHED);
+		flags |= tiler_get_cpu_cache_flags();
 
 		/* align dimensions to slot boundaries... */
 		tiler_align(gem2fmt(flags),
-- 
2.3.3

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

  parent reply	other threads:[~2015-03-24 12:16 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-24 12:15 [PATCH 00/36] drm/omap: patches for 4.1 Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 01/36] drm: omapdrm: Fix indentation of structure and array initializers Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 02/36] drm: omapdrm: Refactor CRTC creation code Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 03/36] drm: omapdrm: Remove unused variables Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 04/36] drm: omapdrm: Switch to the universal plane API Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 05/36] drm: omapdrm: Rename omap_plane_dpms() to omap_plane_set_enable() Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 06/36] drm: omapdrm: Reset the zorder property when disabling a plane Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 07/36] drm: omapdrm: Fix race condition between GO and vblank IRQ Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 08/36] drm: omapdrm: Remove manual update display support Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 09/36] drm: omapdrm: Remove omap_crtc->full_update field Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 10/36] drm: omapdrm: Avoid function forward declaration in omap_crtc.c Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 11/36] drm: omapdrm: Prefix all plane functions with omap_plane_ Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 12/36] drm: omapdrm: Pass integer source coordinates to omap_plane_mode_set() Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 13/36] drm: omapdrm: Planes are already disabled when destroyed Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 14/36] drm: omapdrm: Reorder CRTC functions Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 15/36] drm/omap: fix encoder-crtc mapping Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 16/36] drm/omap: page_flip: return -EBUSY if flip pending Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 17/36] drm/omap: clear omap_obj->paddr in omap_gem_put_paddr() Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 18/36] drm/omap: add pin refcounting to omap_framebuffer Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 19/36] drm/omap: add a comment why locking is missing Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 20/36] drm/omap: fix operation without fbdev Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 21/36] drm/omap: fix error handling in omap_framebuffer_create() Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 22/36] drm/omap: handle incompatible buffer stride and pixel size Tomi Valkeinen
2015-03-24 12:15 ` Tomi Valkeinen [this message]
2015-03-24 12:15 ` [PATCH 24/36] drm/omap: fix plane's channel selection Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 25/36] drm/omap: tiler: fix race condition with engine->async Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 26/36] drm/omap: remove dummy PM functions Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 27/36] drm/omap: stop connector polling during suspend Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 28/36] drm/omap: use DRM_ERROR_RATELIMITED() for error irqs Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 29/36] drm/omap: fix race with error_irq Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 30/36] drm/omap: only ignore DIGIT SYNC LOST for TV output Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 31/36] drm/omap: do not use BUG_ON(!spin_is_locked(x)) Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 32/36] drm/omap: fix race condition with dev->obj_list Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 33/36] drm/omap: fix race conditon in DMM Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 34/36] drm/omap: keep ref to old_fb Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 35/36] drm/omap: add hibernation callbacks Tomi Valkeinen
2015-03-24 12:15 ` [PATCH 36/36] drm/omap: tiler: add hibernation callback Tomi Valkeinen

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=1427199353-4412-24-git-send-email-tomi.valkeinen@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.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.