Skip to contentSkip to conversation

drm/i915: add in-kernel blitter client

PATCH In review Matthew Auld 3 participants 5 messages Apr 26, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: add in-kernel blitter client

The plan is to use the blitter engine for async object clearing when using local memory, but before we can move the worker to get_pages() we have to first tame some more of our struct_mutex usage. With this in mind we should be able to upstream the object clearing as some selftests, which should serve as a guinea pig for the ongoing locking rework and upcoming asyc get_pages() framework.

---
 drivers/gpu/drm/i915/Makefile                 |   2 +
 drivers/gpu/drm/i915/gt/intel_gpu_commands.h  |   1 +
 drivers/gpu/drm/i915/i915_drv.h               |   3 +
 drivers/gpu/drm/i915/i915_gem.c               |   2 +-
 drivers/gpu/drm/i915/i915_gem_client_blt.c    | 186 ++++++++++++++++++
 drivers/gpu/drm/i915/i915_gem_client_blt.h    |  21 ++
 drivers/gpu/drm/i915/i915_gem_object_blt.c    |  91 +++++++++
 drivers/gpu/drm/i915/i915_gem_object_blt.h    |  23 +++
 .../drm/i915/selftests/i915_gem_client_blt.c  | 123 ++++++++++++
 .../drm/i915/selftests/i915_gem_object_blt.c  | 111 +++++++++++
 .../drm/i915/selftests/i915_live_selftests.h  |   2 +
 11 files changed, 564 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/i915_gem_client_blt.c
 create mode 100644 drivers/gpu/drm/i915/i915_gem_client_blt.h
 create mode 100644 drivers/gpu/drm/i915/i915_gem_object_blt.c
 create mode 100644 drivers/gpu/drm/i915/i915_gem_object_blt.h
 create mode 100644 drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c
 create mode 100644 drivers/gpu/drm/i915/selftests/i915_gem_object_blt.c
drivers/gpu/drm/i915/Makefile +2 -0
index 58643373495c..fc123221304e 100644
@@ -90,6 +90,7 @@ i915-y += \
 	  i915_cmd_parser.o \
 	  i915_gem_batch_pool.o \
 	  i915_gem_clflush.o \
+	  i915_gem_client_blt.o \
 	  i915_gem_context.o \
 	  i915_gem_dmabuf.o \
 	  i915_gem_evict.o \
@@ -99,6 +100,7 @@ i915-y += \
 	  i915_gem_internal.o \
 	  i915_gem.o \
 	  i915_gem_object.o \
+	  i915_gem_object_blt.o \
 	  i915_gem_pm.o \
 	  i915_gem_render_state.o \
 	  i915_gem_shrinker.o \
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +1 -0
index a34ece53a771..7e95827b0726 100644
@@ -180,6 +180,7 @@
 #define GFX_OP_DRAWRECT_INFO_I965  ((0x7900<<16)|0x2)
 
 #define COLOR_BLT_CMD			(2<<29 | 0x40<<22 | (5-2))
+#define XY_COLOR_BLT_CMD		(2<<29 | 0x50<<22)
 #define SRC_COPY_BLT_CMD		((2<<29)|(0x43<<22)|4)
 #define XY_SRC_COPY_BLT_CMD		((2<<29)|(0x53<<22)|6)
 #define XY_MONO_SRC_COPY_IMM_BLT	((2<<29)|(0x71<<22)|5)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 1cea98f8b85c..61f95391edf0 100644
@@ -2945,6 +2945,9 @@ dma_addr_t
 i915_gem_object_get_dma_address(struct drm_i915_gem_object *obj,
 				unsigned long n);
 
+struct sg_table *
+__i915_gem_object_unset_pages(struct drm_i915_gem_object *obj);
+
 void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
 				 struct sg_table *pages,
 				 unsigned int sg_page_sizes);
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 4c1793b1012e..65b6d7b7b624 100644
@@ -2121,7 +2121,7 @@ static void __i915_gem_object_reset_page_iter(struct drm_i915_gem_object *obj)
 	rcu_read_unlock();
 }
 
-static struct sg_table *
+struct sg_table *
 __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj)
 {
 	struct drm_i915_private *i915 = to_i915(obj->base.dev);
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +186 -0

186 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem_client_blt.h new file +21 -0
new file mode 100644
index 000000000000..8a0699648b02
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+#ifndef __I915_GEM_CLIENT_BLT_H__
+#define __I915_GEM_CLIENT_BLT_H__
+
+#include <linux/types.h>
+
+struct drm_i915_gem_object;
+struct intel_context *ce;
+struct sg_table;
+
+int i915_gem_schedule_fill_pages_blt(struct drm_i915_gem_object *obj,
+				     struct intel_context *ce,
+				     struct sg_table *pages,
+				     unsigned int page_sizes,
+				     u64 size,
+				     u32 value);
+
+#endif
drivers/gpu/drm/i915/i915_gem_object_blt.c new file +91 -0

91 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem_object_blt.h new file +23 -0
new file mode 100644
index 000000000000..2b25a164d23b
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __I915_GEM_OBJECT_BLT_H__
+#define __I915_GEM_OBJECT_BLT_H__
+
+#include <linux/types.h>
+
+struct drm_i915_gem_object;
+struct intel_context;
+struct i915_vma;
+
+int i915_vma_fill_blt(struct intel_context *ce,
+		      struct i915_vma *vma,
+		      u32 value);
+
+int i915_gem_object_fill_blt(struct intel_context *ce,
+			     struct drm_i915_gem_object *obj,
+			     u32 value);
+
+#endif
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +123 -0

123 lines not on this page · raw message

drivers/gpu/drm/i915/selftests/i915_gem_object_blt.c new file +111 -0

111 lines not on this page · raw message

drivers/gpu/drm/i915/selftests/i915_live_selftests.h +2 -0
index 6d766925ad04..3797574e1984 100644
@@ -23,6 +23,8 @@ selftest(gem, i915_gem_live_selftests)
 selftest(evict, i915_gem_evict_live_selftests)
 selftest(hugepages, i915_gem_huge_page_live_selftests)
 selftest(contexts, i915_gem_context_live_selftests)
+selftest(blt, i915_gem_object_blt_live_selftests)
+selftest(client, i915_gem_client_blt_live_selftests)
 selftest(hangcheck, intel_hangcheck_live_selftests)
 selftest(execlists, intel_execlists_live_selftests)
 selftest(guc, intel_guc_live_selftest)
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✗ Fi.CI.CHECKPATCH: warning for drm/i915: add in-kernel blitter client

== Series Details ==

== Series Details ==

Series: drm/i915: add in-kernel blitter client
URL : https://patchwork.freedesktop.org/series/60017/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
658ea31e573a drm/i915: add in-kernel blitter client
-:43: CHECK:SPACING: spaces preferred around that '<<' (ctx:VxV)
#43: FILE: drivers/gpu/drm/i915/gt/intel_gpu_commands.h:183:
+#define XY_COLOR_BLT_CMD		(2<<29 | 0x50<<22)
                         		  ^

-:43: CHECK:SPACING: spaces preferred around that '<<' (ctx:VxV) #43: FILE: drivers/gpu/drm/i915/gt/intel_gpu_commands.h:183:
+#define XY_COLOR_BLT_CMD (2<<29 | 0x50<<22)

                         		             ^

-:75: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #75:
new file mode 100644

-:228: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!work" #228: FILE: drivers/gpu/drm/i915/i915_gem_client_blt.c:149:
+ if (work == NULL) {

-:328: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV) #328: FILE: drivers/gpu/drm/i915/i915_gem_object_blt.c:30:
+ *cs++ = XY_COLOR_BLT_CMD | BLT_WRITE_RGBA | (7-2);
^

-:337: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV) #337: FILE: drivers/gpu/drm/i915/i915_gem_object_blt.c:39:
+ *cs++ = XY_COLOR_BLT_CMD | BLT_WRITE_RGBA | (6-2);
^

-:441: WARNING:LINE_SPACING: Missing a blank line after declarations #441: FILE: drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c:17:
+ struct rnd_state prng;
+ IGT_TIMEOUT(end);

-:570: WARNING:LINE_SPACING: Missing a blank line after declarations #570: FILE: drivers/gpu/drm/i915/selftests/i915_gem_object_blt.c:17:
+ struct rnd_state prng;
+ IGT_TIMEOUT(end);

total: 0 errors, 3 warnings, 5 checks, 601 lines checked

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✗ Fi.CI.SPARSE: warning for drm/i915: add in-kernel blitter client

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: drm/i915: add in-kernel blitter client
URL : https://patchwork.freedesktop.org/series/60017/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.5.2
Commit: drm/i915: add in-kernel blitter client
+drivers/gpu/drm/i915/i915_gem_client_blt.h:11:22: warning: symbol 'ce' was not declared. Should it be static?
-drivers/gpu/drm/i915/selftests/../i915_drv.h:3570:16: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/selftests/../i915_drv.h:3573:16: warning: expression using sizeof(void)
+./include/linux/reservation.h:220:20: warning: dereference of noderef expression
+./include/linux/reservation.h:220:45: warning: dereference of noderef expression
+./include/uapi/linux/perf_event.h:147:56: warning: cast truncates bits from constant value (8000000000000000 becomes 0)
+./include/uapi/linux/perf_event.h:147:56: warning: cast truncates bits from constant value (8000000000000000 becomes 0)

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
In reply to Matthew Auld

Quoting Matthew Auld (2019-04-26 23:17:05)

Quoted 108 lines

The plan is to use the blitter engine for async object clearing when using local memory, but before we can move the worker to get_pages() we have to first tame some more of our struct_mutex usage. With this in mind we should be able to upstream the object clearing as some selftests, which should serve as a guinea pig for the ongoing locking rework and upcoming asyc get_pages() framework.

---
 drivers/gpu/drm/i915/Makefile                 |   2 +
 drivers/gpu/drm/i915/gt/intel_gpu_commands.h  |   1 +
 drivers/gpu/drm/i915/i915_drv.h               |   3 +
 drivers/gpu/drm/i915/i915_gem.c               |   2 +-
 drivers/gpu/drm/i915/i915_gem_client_blt.c    | 186 ++++++++++++++++++
 drivers/gpu/drm/i915/i915_gem_client_blt.h    |  21 ++
 drivers/gpu/drm/i915/i915_gem_object_blt.c    |  91 +++++++++
 drivers/gpu/drm/i915/i915_gem_object_blt.h    |  23 +++
 .../drm/i915/selftests/i915_gem_client_blt.c  | 123 ++++++++++++
 .../drm/i915/selftests/i915_gem_object_blt.c  | 111 +++++++++++
 .../drm/i915/selftests/i915_live_selftests.h  |   2 +
 11 files changed, 564 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/i915_gem_client_blt.c
 create mode 100644 drivers/gpu/drm/i915/i915_gem_client_blt.h
 create mode 100644 drivers/gpu/drm/i915/i915_gem_object_blt.c
 create mode 100644 drivers/gpu/drm/i915/i915_gem_object_blt.h
 create mode 100644 drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c
 create mode 100644 drivers/gpu/drm/i915/selftests/i915_gem_object_blt.c
drivers/gpu/drm/i915/Makefile +2 -0
index 58643373495c..fc123221304e 100644
@@ -90,6 +90,7 @@ i915-y += \
          i915_cmd_parser.o \
          i915_gem_batch_pool.o \
          i915_gem_clflush.o \
+         i915_gem_client_blt.o \
          i915_gem_context.o \
          i915_gem_dmabuf.o \
          i915_gem_evict.o \
@@ -99,6 +100,7 @@ i915-y += \
          i915_gem_internal.o \
          i915_gem.o \
          i915_gem_object.o \
+         i915_gem_object_blt.o \
          i915_gem_pm.o \
          i915_gem_render_state.o \
          i915_gem_shrinker.o \
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +1 -0
index a34ece53a771..7e95827b0726 100644
@@ -180,6 +180,7 @@
 #define GFX_OP_DRAWRECT_INFO_I965  ((0x7900<<16)|0x2)
 
 #define COLOR_BLT_CMD                  (2<<29 | 0x40<<22 | (5-2))
+#define XY_COLOR_BLT_CMD               (2<<29 | 0x50<<22)
 #define SRC_COPY_BLT_CMD               ((2<<29)|(0x43<<22)|4)
 #define XY_SRC_COPY_BLT_CMD            ((2<<29)|(0x53<<22)|6)
 #define XY_MONO_SRC_COPY_IMM_BLT       ((2<<29)|(0x71<<22)|5)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 1cea98f8b85c..61f95391edf0 100644
@@ -2945,6 +2945,9 @@ dma_addr_t
 i915_gem_object_get_dma_address(struct drm_i915_gem_object *obj,
                                unsigned long n);
 
+struct sg_table *
+__i915_gem_object_unset_pages(struct drm_i915_gem_object *obj);
+
 void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
                                 struct sg_table *pages,
                                 unsigned int sg_page_sizes);
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 4c1793b1012e..65b6d7b7b624 100644
@@ -2121,7 +2121,7 @@ static void __i915_gem_object_reset_page_iter(struct drm_i915_gem_object *obj)
        rcu_read_unlock();
 }
 
-static struct sg_table *
+struct sg_table *
 __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj)
 {
        struct drm_i915_private *i915 = to_i915(obj->base.dev);
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +15 -0
new file mode 100644
index 000000000000..7fd977d54b57
@@ -0,0 +1,186 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+#include "i915_gem_client_blt.h"
+
+#include "i915_gem_object_blt.h"
+#include "intel_drv.h"
+
+static struct drm_i915_gem_object *
+create_sleeve(struct drm_i915_private *i915,
+             struct sg_table *pages,
+             unsigned int page_sizes,
+             u64 size)
+{

drivers/gpu/drm/i915/i915_gem_client_blt.c line 25

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +10 -0
+       struct drm_i915_gem_object *sleeve;
+
+       /* XXX: sketchy af */
+       sleeve = i915_gem_object_create_internal(i915, size);
+       if (IS_ERR(sleeve))
+               return sleeve;
+
+       mutex_lock(&sleeve->mm.lock);
+
+       atomic_inc(&sleeve->mm.pages_pin_count);

I concur with the sketchiness.

I think the basic problem here is that this is operating on the whole level -- I think it will work better at the vma, as we can fill in vma->pages however we wish, and quite naturally fits in with the sg floating around get_pages.

Quoted 44 lines
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +43 -0
+       __i915_gem_object_set_pages(sleeve, pages, page_sizes);
+
+       mutex_unlock(&sleeve->mm.lock);
+
+       return sleeve;
+}
 
+struct clear_pages_work {
+       struct dma_fence dma;
+       struct i915_sw_fence wait;
+       struct work_struct work;
+       struct drm_i915_gem_object *sleeve;
+       struct drm_i915_gem_object *obj;
+       struct intel_context *ce;
+       u32 value;
+};
+
+static const char *clear_pages_work_driver_name(struct dma_fence *fence)
+{
+       return DRIVER_NAME;
+}
+
+static const char *clear_pages_work_timeline_name(struct dma_fence *fence)
+{
+       return "clear";
+}
+
+static void clear_pages_work_release(struct dma_fence *fence)
+{
+       struct clear_pages_work *w = container_of(fence, typeof(*w), dma);
+
+       i915_sw_fence_fini(&w->wait);
+
+       BUILD_BUG_ON(offsetof(typeof(*w), dma));
+       dma_fence_free(&w->dma);
+}
+
+static const struct dma_fence_ops clear_pages_work_ops = {
+       .get_driver_name = clear_pages_work_driver_name,
+       .get_timeline_name = clear_pages_work_timeline_name,
+       .release = clear_pages_work_release,
+};
+
+/* XXX: needs to be taken out and shot */

drivers/gpu/drm/i915/i915_gem_client_blt.c line 91

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +10 -0
+static void i915_clear_pages_worker(struct work_struct *work)
+{
+       struct clear_pages_work *w = container_of(work, typeof(*w), work);
+       struct drm_i915_private *i915 = w->ce->gem_context->i915;
+       intel_wakeref_t wakeref;
+       int err;
+
+       mutex_lock(&i915->drm.struct_mutex);
+
+       wakeref = intel_runtime_pm_get(i915);

We've already killed this requirement with the GEM wakeref reworking, so you drop the wakeref here.

drivers/gpu/drm/i915/i915_gem_client_blt.c line 99

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +8 -0
+
+       err = i915_gem_object_fill_blt(w->ce, w->sleeve, w->value);
+       if (unlikely(err))
+               dma_fence_set_error(&w->dma, err);
+
+       err = i915_gem_object_unbind(w->sleeve);
+       if (unlikely(err))
+               dma_fence_set_error(&w->dma, err);

This is unwanted synchronisation -- you've put the fence into the object, synchronisation with subsequent ops and access is controlled already.

That does mean you have to handle the active reference instead (for the next week or so that remains!)

drivers/gpu/drm/i915/i915_gem_client_blt.c line 109

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +10 -0
+
+       intel_runtime_pm_put(i915, wakeref);
+
+       mutex_unlock(&i915->drm.struct_mutex);
+
+       i915_gem_object_put(w->obj);
+
+       destroy_sleeve(w->sleeve);
+
+       dma_fence_signal(&w->dma);

However, the catch is that we can't signal immediately and instead need to install a proxy onto the rq->fence used for fill_blt.

At the moment, that kind of cascades automatically by the vma-move-to-active, but that alone is not sufficient. Anyone who snooped on the object before the worker fired, only has this w->dma fence for their scheduling, yet we do not want them to execute until after the rq->fence.

At a glance, the simplest means is to get the rq back from the blt and use dma_fence_add_callback(&rq->fence, &w->fence_cb); and in that callback do the dma_fence_signal(). Except it is not quite as simple as that as you will need to use an irq_worker to escape from out of the spinlock to avoid inversion.

Quoted 54 lines
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +54 -0
+       dma_fence_put(&w->dma);
+}
+
+static int __i915_sw_fence_call
+clear_pages_work_notify(struct i915_sw_fence *fence,
+                       enum i915_sw_fence_notify state)
+{
+       struct clear_pages_work *w = container_of(fence, typeof(*w), wait);
+
+       switch (state) {
+       case FENCE_COMPLETE:
+               schedule_work(&w->work);
+               break;
+
+       case FENCE_FREE:
+               dma_fence_put(&w->dma);
+               break;
+       }
+
+       return NOTIFY_DONE;
+}
+
+static DEFINE_SPINLOCK(fence_lock);
+
+int i915_gem_schedule_fill_pages_blt(struct drm_i915_gem_object *obj,
+                                    struct intel_context *ce,
+                                    struct sg_table *pages,
+                                    unsigned int page_sizes,
+                                    u64 size,
+                                    u32 value)
+{
+       struct drm_i915_gem_object *sleeve;
+       struct clear_pages_work *work;
+
+       sleeve = create_sleeve(ce->gem_context->i915, pages, page_sizes, size);
+       if (IS_ERR(sleeve))
+               return PTR_ERR(sleeve);
+
+       work = kmalloc(sizeof(*work), GFP_KERNEL);
+       if (work == NULL) {
+               destroy_sleeve(sleeve);
+               return -ENOMEM;
+       }
+
+       work->value = value;
+       work->sleeve = sleeve;
+       work->obj = i915_gem_object_get(obj);
+       work->ce = ce;
+
+       INIT_WORK(&work->work, i915_clear_pages_worker);
+
+       dma_fence_init(&work->dma,
+                      &clear_pages_work_ops,
+                      &fence_lock,

drivers/gpu/drm/i915/i915_gem_client_blt.c line 173

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +10 -0
+                      to_i915(obj->base.dev)->mm.unordered_timeline,
+                      0);
+       i915_sw_fence_init(&work->wait, clear_pages_work_notify);
+
+       dma_fence_get(&work->dma);
+
+       i915_sw_fence_await_reservation(&work->wait,
+                                       obj->resv, NULL,
+                                       true, I915_FENCE_TIMEOUT,
+                                       I915_FENCE_GFP);

For completeness, propagate the error here.

Quoted 89 lines
drivers/gpu/drm/i915/i915_gem_client_blt.c new file +13 -0
+
+       i915_gem_object_lock(obj);
+       reservation_object_add_excl_fence(obj->resv, &work->dma);
+       i915_gem_object_unlock(obj);
+
+       i915_sw_fence_commit(&work->wait);
+
+       return 0;
+}
+
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+#include "selftests/i915_gem_client_blt.c"
+#endif
drivers/gpu/drm/i915/i915_gem_client_blt.h new file +21 -0
new file mode 100644
index 000000000000..8a0699648b02
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+#ifndef __I915_GEM_CLIENT_BLT_H__
+#define __I915_GEM_CLIENT_BLT_H__
+
+#include <linux/types.h>
+
+struct drm_i915_gem_object;
+struct intel_context *ce;
+struct sg_table;
+
+int i915_gem_schedule_fill_pages_blt(struct drm_i915_gem_object *obj,
+                                    struct intel_context *ce,
+                                    struct sg_table *pages,
+                                    unsigned int page_sizes,
+                                    u64 size,
+                                    u32 value);
+
+#endif
drivers/gpu/drm/i915/i915_gem_object_blt.c new file +43 -0
new file mode 100644
index 000000000000..87a6e0e3709e
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#include "i915_gem_object_blt.h"
+
+#include "intel_drv.h"
+
+int i915_vma_fill_blt(struct intel_context *ce,
+                     struct i915_vma *vma,
+                     u32 value)
+{
+       struct drm_i915_private *i915 = vma->vm->i915;
+       struct i915_request *rq;
+       u32 *cs;
+       int err;
+
+       lockdep_assert_held(&i915->drm.struct_mutex);
+
+       GEM_BUG_ON(!intel_context_is_pinned(ce));
+
+       rq = i915_request_create(ce);
+       if (IS_ERR(rq))
+               return PTR_ERR(rq);
+
+       cs = intel_ring_begin(rq, 8);
+
+       if (INTEL_GEN(i915) >= 8) {
+               *cs++ = XY_COLOR_BLT_CMD | BLT_WRITE_RGBA | (7-2);
+               *cs++ = BLT_DEPTH_32 | BLT_ROP_COLOR_COPY | PAGE_SIZE;
+               *cs++ = 0;
+               *cs++ = vma->size >> PAGE_SHIFT << 16 | PAGE_SIZE / 4;
+               *cs++ = lower_32_bits(vma->node.start);
+               *cs++ = upper_32_bits(vma->node.start);
+               *cs++ = value;
+               *cs++ = MI_NOOP;
+       } else {
+               *cs++ = XY_COLOR_BLT_CMD | BLT_WRITE_RGBA | (6-2);
+               *cs++ = BLT_DEPTH_32 | BLT_ROP_COLOR_COPY | PAGE_SIZE;
+               *cs++ = 0;
+               *cs++ = vma->size >> PAGE_SHIFT << 16 | PAGE_SIZE / 4;
+               *cs++ = vma->node.start;

drivers/gpu/drm/i915/i915_gem_object_blt.c line 53

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_object_blt.c new file +10 -0
+               *cs++ = value;
+               *cs++ = MI_NOOP;
+               *cs++ = MI_NOOP;
+       }
+
+       intel_ring_advance(rq, cs);
+
+       err = i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
+       if (err)
+               i915_request_skip(rq, err);

Hmm, I don't think skip works quite right before an add. That needs to be fixed up.

drivers/gpu/drm/i915/i915_gem_object_blt.c line 61

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_object_blt.c new file +8 -0
+
+       i915_request_add(rq);
+
+       return err;
+}
+
+int i915_gem_object_fill_blt(struct intel_context *ce,
+                            struct drm_i915_gem_object *obj,

object should be first arg as it is the object of the function.

Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_object_blt.c new file +11 -0
+                            u32 value)
+{
+       struct drm_i915_private *i915 = to_i915(obj->base.dev);
+       struct i915_gem_context *ctx = ce->gem_context;
+       struct i915_address_space *vm;
+       struct i915_vma *vma;
+       int err;
+
+       lockdep_assert_held(&i915->drm.struct_mutex);
+
+       vm = ctx->ppgtt ? &ctx->ppgtt->vm : &i915->ggtt.vm;

drivers/gpu/drm/i915/i915_gem_object_blt.c line 82

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_object_blt.c new file +10 -0
+
+       vma = i915_vma_instance(obj, vm, NULL);
+       if (IS_ERR(vma))
+               return PTR_ERR(vma);
+
+       err = i915_vma_pin(vma, 0, 0, PIN_USER);
+       if (unlikely(err))
+               return err;
+
+       err = i915_vma_fill_blt(ce, vma, value);

Yeah, definitely thinking the worker should be using a temporary vma and not a dummy obj.

Quoted 68 lines
drivers/gpu/drm/i915/i915_gem_object_blt.c new file +8 -0
+       i915_vma_unpin(vma);
+
+       return err;
+}
+
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+#include "selftests/i915_gem_object_blt.c"
+#endif
drivers/gpu/drm/i915/i915_gem_object_blt.h new file +23 -0
new file mode 100644
index 000000000000..2b25a164d23b
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __I915_GEM_OBJECT_BLT_H__
+#define __I915_GEM_OBJECT_BLT_H__
+
+#include <linux/types.h>
+
+struct drm_i915_gem_object;
+struct intel_context;
+struct i915_vma;
+
+int i915_vma_fill_blt(struct intel_context *ce,
+                     struct i915_vma *vma,
+                     u32 value);
+
+int i915_gem_object_fill_blt(struct intel_context *ce,
+                            struct drm_i915_gem_object *obj,
+                            u32 value);
+
+#endif
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +25 -0
new file mode 100644
index 000000000000..3cd7d208a4a8
@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#include "../i915_selftest.h"
+
+#include "mock_drm.h"
+#include "mock_context.h"
+
+static int igt_client_fill(void *arg)
+{
+       struct intel_context *ce = arg;
+       struct drm_i915_private *i915 = ce->gem_context->i915;
+       struct drm_i915_gem_object *obj;
+       struct rnd_state prng;
+       IGT_TIMEOUT(end);
+       u32 *vaddr;
+       int err = 0;
+
+       obj = i915_gem_object_create_internal(i915, SZ_2M);
+       if (IS_ERR(obj))
+               return PTR_ERR(obj);
+
+       vaddr = i915_gem_object_pin_map(obj, I915_MAP_WB);

drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c line 35

Quoted 10 lines
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +10 -0
+       if (IS_ERR(vaddr)) {
+               err = PTR_ERR(vaddr);
+               goto err_put;
+       }
+
+       prandom_seed_state(&prng, i915_selftest.random_seed);
+
+       do {
+               u32 val = prandom_u32_state(&prng);
+               u32 i;

I think it would be good if it creates a new randomly sized object on each pass as well.

Quoted 7 lines
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +7 -0
+               err = i915_gem_schedule_fill_pages_blt(obj, ce, obj->mm.pages,
+                                                      obj->mm.page_sizes.phys,
+                                                      obj->base.size,
+                                                      val);
+               if (err)
+                       break;
+

drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c line 53

Quoted 10 lines
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +10 -0
+               /*
+                * XXX: For now do the wait without the BKL to ensure we don't
+                * deadlock.
+                */
+               err = i915_gem_object_wait(obj,
+                                          I915_WAIT_INTERRUPTIBLE |
+                                          I915_WAIT_ALL,
+                                          MAX_SCHEDULE_TIMEOUT);
+               if (err)
+                       break;

Lots of work to be done :)

drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c line 57

Quoted 4 lines
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +4 -0
+
+               mutex_lock(&i915->drm.struct_mutex);
+               err = i915_gem_object_set_to_cpu_domain(obj, false);
+               mutex_unlock(&i915->drm.struct_mutex);

The worker never cleaned the caches before blt. Whoops. The challenge is to refine this test to make sure it picks up the current failure :)

Quoted 46 lines
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +46 -0
+               if (err)
+                       break;
+
+               for (i = 0; i < obj->base.size / sizeof(u32); ++i) {
+                       if (vaddr[i] != val) {
+                               pr_err("vaddr[%d]=%u, expected=%u\n", i,
+                                      val, vaddr[i]);
+                               err = -EINVAL;
+                               break;
+                       }
+               }
+       } while (!time_after(jiffies, end));
+
+       i915_gem_object_unpin_map(obj);
+err_put:
+       i915_gem_object_put(obj);
+       return err;
+}
+
+int i915_gem_client_blt_live_selftests(struct drm_i915_private *i915)
+{
+       static const struct i915_subtest tests[] = {
+               SUBTEST(igt_client_fill),
+       };
+       struct drm_file *file;
+       struct i915_gem_context *ctx;
+       struct intel_context *ce;
+       intel_wakeref_t wakeref;
+       int err;
+
+       if (i915_terminally_wedged(i915))
+               return 0;
+
+       if (!HAS_ENGINE(i915, BCS0))
+               return 0;
+
+       file = mock_file(i915);
+       if (IS_ERR(file))
+               return PTR_ERR(file);
+
+       mutex_lock(&i915->drm.struct_mutex);
+       ctx = live_context(i915, file);
+       mutex_unlock(&i915->drm.struct_mutex);
+       if (IS_ERR(ctx)) {
+               err = PTR_ERR(ctx);
+               goto out_free;

drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c line 113

Quoted 10 lines
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +10 -0
+       }
+
+       ce = i915_gem_context_get_engine(ctx, BCS0);
+       if (IS_ERR(ce))
+               goto out_free;
+
+       err = intel_context_pin(ce);
+       intel_context_put(ce);
+       if (err)
+               goto out_free;

Hmm, you want to emulate the in-kernel blitter client, or userspace client? This looks more like userspace.

Otherwise you would just use i915->engine[BCS0]->kernel_context.

drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c line 113

Quoted 1 line
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +1 -0
+       wakeref = intel_runtime_pm_get(i915);

For these tests, we do want to verify the harness is handling wakeref properly -- it will need to be called from any random context.

drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c line 123

Quoted 8 lines
drivers/gpu/drm/i915/selftests/i915_gem_client_blt.c new file +8 -0
+       err = i915_subtests(tests, ce);
+       intel_runtime_pm_put(i915, wakeref);
+
+       intel_context_unpin(ce);
+out_free:
+       mock_file_free(i915, file);
+       return err;
+}

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✗ Fi.CI.BAT: failure for drm/i915: add in-kernel blitter client

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: drm/i915: add in-kernel blitter client
URL : https://patchwork.freedesktop.org/series/60017/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6007 -> Patchwork_12889
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_12889 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_12889, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/60017/revisions/1/mbox/

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_12889:

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_create@basic:
- fi-kbl-7567u: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6007/fi-kbl-7567u/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-kbl-7567u/igt@[email protected]

* igt@gem_exec_fence@nb-await-default:
- fi-kbl-x1275: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6007/fi-kbl-x1275/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-kbl-x1275/igt@[email protected]

* {igt@i915_selftest@live_blt} (NEW):
- fi-bxt-j4205: NOTRUN -> [DMESG-WARN][5]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-bxt-j4205/igt@i915_selftest@live_blt.html
- fi-whl-u: NOTRUN -> [DMESG-WARN][6]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-whl-u/igt@i915_selftest@live_blt.html
- fi-bdw-5557u: NOTRUN -> [DMESG-WARN][7]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-bdw-5557u/igt@i915_selftest@live_blt.html
- fi-icl-u3: NOTRUN -> [DMESG-WARN][8]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-icl-u3/igt@i915_selftest@live_blt.html
- {fi-cml-u}: NOTRUN -> [DMESG-WARN][9]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-cml-u/igt@i915_selftest@live_blt.html
- fi-cfl-8109u: NOTRUN -> [DMESG-WARN][10]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-cfl-8109u/igt@i915_selftest@live_blt.html
- fi-skl-lmem: NOTRUN -> [DMESG-WARN][11]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-skl-lmem/igt@i915_selftest@live_blt.html
- fi-kbl-8809g: NOTRUN -> [DMESG-WARN][12]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-kbl-8809g/igt@i915_selftest@live_blt.html
- fi-hsw-4770r: NOTRUN -> [DMESG-WARN][13]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-hsw-4770r/igt@i915_selftest@live_blt.html
- fi-hsw-peppy: NOTRUN -> [DMESG-WARN][14]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-hsw-peppy/igt@i915_selftest@live_blt.html
- fi-skl-6600u: NOTRUN -> [DMESG-WARN][15]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-skl-6600u/igt@i915_selftest@live_blt.html
- fi-bdw-gvtdvm: NOTRUN -> [DMESG-WARN][16]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-bdw-gvtdvm/igt@i915_selftest@live_blt.html
- fi-skl-gvtdvm: NOTRUN -> [DMESG-WARN][17]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-skl-gvtdvm/igt@i915_selftest@live_blt.html
- fi-skl-6260u: NOTRUN -> [DMESG-WARN][18]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-skl-6260u/igt@i915_selftest@live_blt.html

* igt@runner@aborted:
- fi-bdw-gvtdvm: NOTRUN -> [FAIL][19]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-bdw-gvtdvm/igt@[email protected]
- fi-hsw-4770r: NOTRUN -> [FAIL][20]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-hsw-4770r/igt@[email protected]
- fi-cfl-8109u: NOTRUN -> [FAIL][21]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-cfl-8109u/igt@[email protected]
- fi-hsw-peppy: NOTRUN -> [FAIL][22]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-hsw-peppy/igt@[email protected]
- fi-kbl-8809g: NOTRUN -> [FAIL][23]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-kbl-8809g/igt@[email protected]
- fi-bdw-5557u: NOTRUN -> [FAIL][24]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-bdw-5557u/igt@[email protected]
- fi-bxt-j4205: NOTRUN -> [FAIL][25]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-bxt-j4205/igt@[email protected]
- fi-whl-u: NOTRUN -> [FAIL][26]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-whl-u/igt@[email protected]
- fi-icl-u3: NOTRUN -> [FAIL][27]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-icl-u3/igt@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@runner@aborted:
- {fi-cml-u}: NOTRUN -> [FAIL][28]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-cml-u/igt@[email protected]

New tests
---------

New tests have been introduced between CI_DRM_6007 and Patchwork_12889:

### New IGT tests (2) ###

* igt@i915_selftest@live_blt:
- Statuses : 14 dmesg-warn(s) 3 pass(s)
- Exec time: [0.38, 1.71] s

* igt@i915_selftest@live_client:
- Statuses : 3 pass(s)
- Exec time: [0.39, 0.46] s

Known issues
------------

Here are the changes found in Patchwork_12889 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live_contexts:
- fi-bdw-gvtdvm: [PASS][29] -> [DMESG-FAIL][30] ([fdo#110235 ])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6007/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#110235 ]: https://bugs.freedesktop.org/show_bug.cgi?id=110235

Participating hosts (38 -> 23)
------------------------------

Additional (1): fi-icl-u3
Missing (16): fi-ilk-m540 fi-bxt-dsi fi-byt-j1900 fi-skl-6770hq fi-skl-guc fi-byt-squawks fi-bsw-cyan fi-bwr-2160 fi-snb-2520m fi-cfl-8700k fi-ivb-3770 fi-skl-iommu fi-bsw-kefka fi-byt-n2820 fi-byt-clapper fi-skl-6700k2

Build changes
-------------

* Linux: CI_DRM_6007 -> Patchwork_12889

CI_DRM_6007: 846376257e91f6e49cf7d6b59b0a6cbb0ce7cd53 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4968: caed251990f35bfe45368f803980071a73e36315 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12889: 658ea31e573a34a336ad213e86ebb54e6bb81af4 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

658ea31e573a drm/i915: add in-kernel blitter client

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12889/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx