All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/ttm: Only try to preserve caching in moves in the same space
@ 2010-01-28  9:26 Luca Barbieri
  2010-02-01  1:35 ` Dave Airlie
  0 siblings, 1 reply; 10+ messages in thread
From: Luca Barbieri @ 2010-01-28  9:26 UTC (permalink / raw)
  To: thellstrom; +Cc: airlied, Luca Barbieri, dri-devel

Currently TTM tries to preserve the previous caching even for moves
between unrelated memory spaces.

This results for instance in moves from VRAM to PCIE GART changing
system memory to WC state needlessly.

This patch changes TTM to only try to preserve caching if moving from
system/TT to system/TT.

In theory, we should also do that if moving between two device memory
spaces that are backend by the same physical memory area.
However, I'm not sure how to do that in the current TTM framework and
I suspect no card/driver uses memory spaces in that way.

Signed-off-by: Luca Barbieri <luca@luca-barbieri.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 2920f9a..27ee1be 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -876,6 +876,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 
 	mem->mm_node = NULL;
 	for (i = 0; i < placement->num_placement; ++i) {
+		int is_tt_move;
 		ret = ttm_mem_type_from_flags(placement->placement[i],
 						&mem_type);
 		if (ret)
@@ -891,8 +892,12 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 		if (!type_ok)
 			continue;
 
-		cur_flags = ttm_bo_select_caching(man, bo->mem.placement,
-						  cur_flags);
+		is_tt_move = !(man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
+			!(bdev->man[bo->mem.mem_type].flags & TTM_MEMTYPE_FLAG_FIXED);
+
+		/* Only try to keep the current flags if we are in the same memory space */
+		cur_flags = ttm_bo_select_caching(man, is_tt_move ? bo->mem.placement : 0, cur_flags);
+
 		/*
 		 * Use the access and other non-mapping-related flag bits from
 		 * the memory placement flags to the current flags
@@ -927,6 +932,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 		return -EINVAL;
 
 	for (i = 0; i < placement->num_busy_placement; ++i) {
+		int is_tt_move;
 		ret = ttm_mem_type_from_flags(placement->busy_placement[i],
 						&mem_type);
 		if (ret)
@@ -941,8 +947,12 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 						&cur_flags))
 			continue;
 
-		cur_flags = ttm_bo_select_caching(man, bo->mem.placement,
-						  cur_flags);
+		is_tt_move = !(man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
+			!(bdev->man[bo->mem.mem_type].flags & TTM_MEMTYPE_FLAG_FIXED);
+
+		/* Only try to keep the current flags if we are in the same memory space */
+		cur_flags = ttm_bo_select_caching(man, is_tt_move ? bo->mem.placement : 0, cur_flags);
+
 		/*
 		 * Use the access and other non-mapping-related flag bits from
 		 * the memory placement flags to the current flags
-- 
1.6.6.1.476.g01ddb


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-02-01 18:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-28  9:26 [PATCH] drm/ttm: Only try to preserve caching in moves in the same space Luca Barbieri
2010-02-01  1:35 ` Dave Airlie
2010-02-01 13:33   ` Jerome Glisse
2010-02-01 16:18     ` Thomas Hellstrom
2010-02-01 16:26     ` Luca Barbieri
2010-02-01 16:28       ` Luca Barbieri
2010-02-01 17:05       ` Jerome Glisse
2010-02-01 17:46         ` Luca Barbieri
2010-02-01 18:05           ` Jerome Glisse
2010-02-01 18:21             ` Luca Barbieri

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.