]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: s/for_each_sgt_dma/for_each_sgt_daddr/
authorMatthew Auld <matthew.auld@intel.com>
Thu, 29 Aug 2019 20:19:19 +0000 (21:19 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 29 Aug 2019 20:59:16 +0000 (21:59 +0100)
The sg_table for our backing store might contain addresses from
stolen-memory or in the future local-memory, at which point this is no
longer a dma-iterator. As a consequence we should now break on NULL
iter.sgp, instead of dmap == 0 which is considered an invalid dma
address.

As a bonus, gcc much prefers this construct,

  Function                                     old     new   delta
  gen8_ggtt_insert_entries                     211     192     -19
  gen6_ggtt_insert_entries                     292     262     -30
  i915_error_object_create                     996     954     -42

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190829201919.21493-1-matthew.auld@intel.com
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_gtt.h
drivers/gpu/drm/i915/i915_gpu_error.c
drivers/gpu/drm/i915/i915_scatterlist.h
drivers/gpu/drm/i915/selftests/i915_vma.c

index c94dfa5622474bc83ec528d2d5f0a8bf944eafa1..3c50cea76dc5c733d6507923b0e07655d31d952f 100644 (file)
@@ -2208,7 +2208,7 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,
 
        gtt_entries = (gen8_pte_t __iomem *)ggtt->gsm;
        gtt_entries += vma->node.start / I915_GTT_PAGE_SIZE;
-       for_each_sgt_dma(addr, sgt_iter, vma->pages)
+       for_each_sgt_daddr(addr, sgt_iter, vma->pages)
                gen8_set_pte(gtt_entries++, pte_encode | addr);
 
        /*
@@ -2249,7 +2249,7 @@ static void gen6_ggtt_insert_entries(struct i915_address_space *vm,
        unsigned int i = vma->node.start / I915_GTT_PAGE_SIZE;
        struct sgt_iter iter;
        dma_addr_t addr;
-       for_each_sgt_dma(addr, iter, vma->pages)
+       for_each_sgt_daddr(addr, iter, vma->pages)
                iowrite32(vm->pte_encode(addr, level, flags), &entries[i++]);
 
        /*
index b97a47fc7a68a940e1b91912689e053ad207b582..576f6fb95d135f95007533c6ccdf110aaf86db94 100644 (file)
@@ -148,8 +148,8 @@ typedef u64 gen8_pte_t;
 #define GEN8_PDE_IPS_64K BIT(11)
 #define GEN8_PDE_PS_2M   BIT(7)
 
-#define for_each_sgt_dma(__dmap, __iter, __sgt) \
-       __for_each_sgt_dma(__dmap, __iter, __sgt, I915_GTT_PAGE_SIZE)
+#define for_each_sgt_daddr(__dp, __iter, __sgt) \
+       __for_each_sgt_daddr(__dp, __iter, __sgt, I915_GTT_PAGE_SIZE)
 
 struct intel_remapped_plane_info {
        /* in gtt pages */
index 4aff342b89443fe71febb43d3009b07e4afb8256..3ccf7fd9307f3988c915af186ef143529858b439 100644 (file)
@@ -990,7 +990,7 @@ i915_error_object_create(struct drm_i915_private *i915,
        dst->unused = 0;
 
        ret = -EINVAL;
-       for_each_sgt_dma(dma, iter, vma->pages) {
+       for_each_sgt_daddr(dma, iter, vma->pages) {
                void __iomem *s;
 
                ggtt->vm.insert_page(&ggtt->vm, dma, slot, I915_CACHE_NONE, 0);
index 6617963df9ed2fa2f0327f908571b785d7691433..b7b59328cb76abdb2c598349b33b5b32e5aa406b 100644 (file)
@@ -67,15 +67,15 @@ static inline struct scatterlist *__sg_next(struct scatterlist *sg)
 }
 
 /**
- * __for_each_sgt_dma - iterate over the DMA addresses of the given sg_table
- * @__dmap:    DMA address (output)
+ * __for_each_sgt_daddr - iterate over the device addresses of the given sg_table
+ * @__dp:      Device address (output)
  * @__iter:    'struct sgt_iter' (iterator state, internal)
  * @__sgt:     sg_table to iterate over (input)
  * @__step:    step size
  */
-#define __for_each_sgt_dma(__dmap, __iter, __sgt, __step)              \
+#define __for_each_sgt_daddr(__dp, __iter, __sgt, __step)              \
        for ((__iter) = __sgt_iter((__sgt)->sgl, true);                 \
-            ((__dmap) = (__iter).dma + (__iter).curr);                 \
+            ((__dp) = (__iter).dma + (__iter).curr), (__iter).sgp;     \
             (((__iter).curr += (__step)) >= (__iter).max) ?            \
             (__iter) = __sgt_iter(__sg_next((__iter).sgp), true), 0 : 0)
 
index a5bec0a4cdcc5db3499d6191d26c4587c27012ed..97752deecccbfb7e436868dd5c2d4a4aeaa0fd40 100644 (file)
@@ -623,7 +623,7 @@ static bool assert_partial(struct drm_i915_gem_object *obj,
        struct sgt_iter sgt;
        dma_addr_t dma;
 
-       for_each_sgt_dma(dma, sgt, vma->pages) {
+       for_each_sgt_daddr(dma, sgt, vma->pages) {
                dma_addr_t src;
 
                if (!size) {