Since the processor may not support vmap with WC, or the system may be
limited in virtual address space and so may fail to create such a vmap,
fallback to using a plain kmap of the system pages and flush the buffer
on completion.

Reported-by: Pavel Machek <pa...@ucw.cz>
Fixes: 964a9b0f611e ("drm/i915/gem: Use chained reloc batches")
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahti...@linux.intel.com>
Cc: Pavel Machek <pa...@ucw.cz>
Cc: <sta...@vger.kernel.org> # v5.8+
---
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c    | 25 +++++++++++++------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index a09f04eee417..44df98d85b38 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -950,6 +950,21 @@ static void reloc_cache_init(struct reloc_cache *cache,
 
 #define RELOC_TAIL 4
 
+static u32 *__reloc_gpu_map(struct reloc_cache *cache,
+                           struct intel_gt_buffer_pool_node *pool)
+{
+       u32 *map;
+
+       map = i915_gem_object_pin_map(pool->obj,
+                                     cache->has_llc ?
+                                     I915_MAP_FORCE_WB :
+                                     I915_MAP_FORCE_WC);
+       if (IS_ERR(map)) /* try a plain kmap (and flush) if no WC maps */
+               map = i915_gem_object_pin_map(pool->obj, I915_MAP_FORCE_WB);
+
+       return map;
+}
+
 static int reloc_gpu_chain(struct reloc_cache *cache)
 {
        struct intel_gt_buffer_pool_node *pool;
@@ -996,10 +1011,7 @@ static int reloc_gpu_chain(struct reloc_cache *cache)
        *cmd++ = lower_32_bits(batch->node.start);
        *cmd++ = upper_32_bits(batch->node.start); /* Always 0 for gen<8 */
 
-       cmd = i915_gem_object_pin_map(batch->obj,
-                                     cache->has_llc ?
-                                     I915_MAP_FORCE_WB :
-                                     I915_MAP_FORCE_WC);
+       cmd = __reloc_gpu_map(cache, pool);
        if (IS_ERR(cmd)) {
                /* We will replace the BBS with BBE upon flushing the rq */
                err = PTR_ERR(cmd);
@@ -1096,10 +1108,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
        if (IS_ERR(pool))
                return PTR_ERR(pool);
 
-       cmd = i915_gem_object_pin_map(pool->obj,
-                                     cache->has_llc ?
-                                     I915_MAP_FORCE_WB :
-                                     I915_MAP_FORCE_WC);
+       cmd = __reloc_gpu_map(cache, pool);
        if (IS_ERR(cmd)) {
                err = PTR_ERR(cmd);
                goto out_pool;
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to