> >>>       
> >> OK. We're using this functionality in Poulsbo, so we should probably
> >> sort this out to avoid breaking things.
> >>     
> >
> > Okay I'll try and fix it back up tomorrow.. 
> >

I've attached my first attempt at fixing this up but it messes up by the 
time the flags hit the ttm binding function they've lost the CACHED_MAPPED 
bit and I end up with snooped bindings, drm_bo_mt_compatible seems to be 
where it disappears and also where my sanity started to end.. are you sure 
there isn't a nicer way of doing those flags/mask because the current 
system is vastly confusing to trace through..

Can you suggest what I'm missing to fix this up?

Dave.
diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c
index 8c7f570..4015659 100644
--- a/linux-core/drm_agpsupport.c
+++ b/linux-core/drm_agpsupport.c
@@ -541,11 +541,17 @@ static int drm_agp_bind_ttm(struct drm_ttm_backend 
*backend,
                container_of(backend, struct drm_agp_ttm_backend, backend);
        DRM_AGP_MEM *mem = agp_be->mem;
        int ret;
+       int snooped = (bo_mem->flags & DRM_BO_FLAG_CACHED) && !(bo_mem->flags & 
DRM_BO_FLAG_CACHED_MAPPED);
 
        DRM_DEBUG("drm_agp_bind_ttm\n");
        mem->is_flushed = TRUE;
-       mem->type = (bo_mem->flags & DRM_BO_FLAG_CACHED) ? 
AGP_USER_CACHED_MEMORY :
-               AGP_USER_MEMORY;
+       mem->type = AGP_USER_MEMORY;
+       /* CACHED MAPPED implies not snooped memory */
+       if (snooped) {
+               DRM_ERROR("snooped is set oh no 0x%016llx\n", (unsigned long 
long)bo_mem->flags);
+               mem->type = AGP_USER_CACHED_MEMORY;
+       }
+
        ret = drm_agp_bind_memory(mem, bo_mem->mm_node->start);
        if (ret) {
                DRM_ERROR("AGP Bind memory failed\n");
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c
index 16203c7..05b9f5a 100644
--- a/linux-core/drm_bo.c
+++ b/linux-core/drm_bo.c
@@ -1029,7 +1029,7 @@ static int drm_bo_busy(struct drm_buffer_object * bo)
        return 0;
 }
 
-static int drm_bo_read_cached(struct drm_buffer_object * bo)
+static int drm_bo_evict_cached(struct drm_buffer_object * bo)
 {
        int ret = 0;
 
@@ -1177,15 +1177,11 @@ static int drm_buffer_object_map(struct drm_file 
*file_priv, uint32_t handle,
                                goto out;
                        }
 
-                       if ((map_flags & DRM_BO_FLAG_READ) &&
-                           (bo->mem.flags & DRM_BO_FLAG_READ_CACHED) &&
-                           (!(bo->mem.flags & DRM_BO_FLAG_CACHED))) {
-                               drm_bo_read_cached(bo);
-                       }
+                       if (bo->mem.flags & DRM_BO_FLAG_CACHED_MAPPED)
+                               drm_bo_evict_cached(bo);
+
                        break;
-               } else if ((map_flags & DRM_BO_FLAG_READ) &&
-                          (bo->mem.flags & DRM_BO_FLAG_READ_CACHED) &&
-                          (!(bo->mem.flags & DRM_BO_FLAG_CACHED))) {
+               } else if (bo->mem.flags & DRM_BO_FLAG_CACHED_MAPPED) {
 
                        /*
                         * We are already mapped with different flags.
@@ -1292,6 +1288,7 @@ int drm_bo_move_buffer(struct drm_buffer_object * bo, 
uint64_t new_mem_flags,
        if (ret)
                return ret;
 
+       DRM_DEBUG("new mem flags 0x%016llx\n", new_mem_flags);
        mem.num_pages = bo->num_pages;
        mem.size = mem.num_pages << PAGE_SHIFT;
        mem.mask = new_mem_flags;
@@ -1666,7 +1663,6 @@ int drm_buffer_object_create(struct drm_device *dev,
                DRM_BO_FLAG_MAPPABLE;
        atomic_inc(&bm->count);
        ret = drm_bo_new_mask(bo, mask, hint);
-
        if (ret)
                goto out_err;
 
diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c
index df9e7e4..83aa28a 100644
--- a/linux-core/drm_ttm.c
+++ b/linux-core/drm_ttm.c
@@ -327,9 +327,10 @@ int drm_bind_ttm(struct drm_ttm * ttm, struct 
drm_bo_mem_reg *bo_mem)
        if (ret)
                return ret;
 
+       DRM_DEBUG("bo->mem flags is 0x%016llx\n", bo_mem->flags);
        if (ttm->state == ttm_unbound && !(bo_mem->flags & DRM_BO_FLAG_CACHED)) 
{
                drm_set_caching(ttm, DRM_TTM_PAGE_UNCACHED);
-       } else if ((bo_mem->flags & DRM_BO_FLAG_CACHED) &&
+       } else if ((bo_mem->flags & DRM_BO_FLAG_CACHED_MAPPED) &&
                   bo_driver->ttm_cache_flush)
                bo_driver->ttm_cache_flush(ttm);
 
diff --git a/shared-core/drm.h b/shared-core/drm.h
index 3a10273..9d00e9f 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -700,10 +700,12 @@ struct drm_fence_arg {
  */
 #define DRM_BO_FLAG_NO_MOVE     (1ULL << 8)
 
-/* Mask: Make sure the buffer is in cached memory when mapped for reading.
+/* Mask: Make sure the buffer is in cached memory when mapped
  * Flags: Acknowledge.
+ * Buffers allocated with this flag should not be used for suballocators
  */
-#define DRM_BO_FLAG_READ_CACHED    (1ULL << 19)
+#define DRM_BO_FLAG_CACHED_MAPPED    (1ULL << 19)
+
 
 /* Mask: Force DRM_BO_FLAG_CACHED flag strictly also if it is set.
  * Flags: Acknowledge.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to