diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-16 00:32:12 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-16 01:30:13 +0000 |
commit | fd4c139a3959df90c7f078817fc6e2f3db715bf8 (patch) | |
tree | 49815a24e8d38618a92f5b3c4255a2df2c27d54d | |
parent | c20a729d0a57fd5a782d9114535d9474f39a8950 (diff) |
sna: On LLC systems quietly replace all linear mmappings using the CPU
If the GPU and CPU caches are shared and coherent, we can use a cached
mapping for linear bo in the CPU domain with no penalty and so avoid the
penalty of using WC/UC mappings through the GTT (and any aperture
pressure). We presume that the bo for such mappings are indeed LLC
cached...
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/kgem.c | 25 | ||||
-rw-r--r-- | src/sna/kgem.h | 2 | ||||
-rw-r--r-- | src/sna/sna.h | 1 | ||||
-rw-r--r-- | src/sna/sna_accel.c | 2 |
4 files changed, 21 insertions, 9 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 0075bedb..d119ae36 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -85,6 +85,7 @@ static inline void list_replace(struct list *old, #define DBG_NO_HW 0 #define DBG_NO_TILING 0 #define DBG_NO_VMAP 0 +#define DBG_NO_LLC 0 #define DBG_NO_SEMAPHORES 0 #define DBG_NO_MADV 0 #define DBG_NO_MAP_UPLOAD 0 @@ -601,6 +602,13 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen) DBG(("%s: has relaxed fencing? %d\n", __FUNCTION__, kgem->has_relaxed_fencing)); + kgem->has_llc = false; + if (!DBG_NO_LLC && gen >= 60) + kgem->has_llc = true; + kgem->has_cpu_bo = kgem->has_llc; + DBG(("%s: cpu bo enabled %d: llc? %d\n", __FUNCTION__, + kgem->has_cpu_bo, kgem->has_llc)); + kgem->has_semaphores = false; if (gen >= 60 && semaphores_enabled()) kgem->has_semaphores = true; @@ -2170,6 +2178,8 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem, if (flags & (CREATE_CPU_MAP | CREATE_GTT_MAP)) { int for_cpu = !!(flags & CREATE_CPU_MAP); + if (kgem->has_llc && tiling == I915_TILING_NONE) + for_cpu = 1; /* We presume that we will need to upload to this bo, * and so would prefer to have an active VMA. */ @@ -2604,14 +2614,15 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo) assert(bo->exec == NULL); assert(list_is_empty(&bo->list)); - if (IS_CPU_MAP(bo->map)) { - if (bo->tiling == I915_TILING_NONE) { - kgem_bo_sync__cpu(kgem, bo); - return CPU_MAP(bo->map); - } - kgem_bo_release_map(kgem, bo); + if (kgem->has_llc && bo->tiling == I915_TILING_NONE) { + ptr = kgem_bo_map__cpu(kgem, bo); + kgem_bo_sync__cpu(kgem, bo); + return ptr; } + if (IS_CPU_MAP(bo->map)) + kgem_bo_release_map(kgem, bo); + ptr = bo->map; if (ptr == NULL) { kgem_trim_vma_cache(kgem, MAP_GTT, bo->bucket); @@ -2958,7 +2969,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, bo = NULL; #if !DBG_NO_MAP_UPLOAD - if (!DEBUG_NO_LLC && kgem->gen >= 60) { + if (kgem->has_cpu_bo) { struct kgem_bo *old; bo = malloc(sizeof(*bo)); diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 377d21d3..621e3cd5 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -146,6 +146,8 @@ struct kgem { uint32_t has_vmap :1; uint32_t has_relaxed_fencing :1; uint32_t has_semaphores :1; + uint32_t has_llc :1; + uint32_t has_cpu_bo :1; uint16_t fence_max; uint16_t half_cpu_cache_pages; diff --git a/src/sna/sna.h b/src/sna/sna.h index 185bc1de..5153d339 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -93,7 +93,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define DEBUG_NO_RENDER 0 #define DEBUG_NO_BLT 0 #define DEBUG_NO_IO 0 -#define DEBUG_NO_LLC 0 #define DEBUG_FLUSH_CACHE 0 #define DEBUG_FLUSH_BATCH 0 diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 16657911..7774cba8 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -205,7 +205,7 @@ sna_pixmap_alloc_cpu(struct sna *sna, assert(priv->stride); - if (!DEBUG_NO_LLC && sna->kgem.gen >= 60) { + if (sna->kgem.has_cpu_bo) { DBG(("%s: allocating CPU buffer (%dx%d)\n", __FUNCTION__, pixmap->drawable.width, pixmap->drawable.height)); |