]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Never allow userptr into the new mapping types
authorJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Tue, 4 Feb 2020 16:23:02 +0000 (16:23 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Sat, 8 Feb 2020 11:26:03 +0000 (11:26 +0000)
Commit 4f2a572eda67 ("drm/i915/userptr: Never allow userptr into the
mappable GGTT") made I915_GEM_MMAP_GTT IOCTLs to fail when attempted
on a userptr object in order to protect from a lockdep splat.  Later
on, new mapping types were introduced by commit cc662126b413
("drm/i915: Introduce DRM_I915_GEM_MMAP_OFFSET").  Those new mapping
types suffer from the same lockdep splat issue but they now succeed
when tried on top of a userptr object.  Fix it.

v2: Don't play with the -ENODEV driver response (Chris)

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: Abdiel Janulgue <abdiel.janulgue@linux.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/20200204162302.1299516-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gem/i915_gem_mman.c
drivers/gpu/drm/i915/gem/i915_gem_object.h
drivers/gpu/drm/i915/gem/i915_gem_object_types.h
drivers/gpu/drm/i915/gem/i915_gem_userptr.c
drivers/gpu/drm/i915/i915_gem.c

index 0b6a442108de0ee14805438aacc59c919ce4e26e..e8cccc131c40f066c3aefc005299e5a1512d25dd 100644 (file)
@@ -613,8 +613,7 @@ __assign_mmap_offset(struct drm_file *file,
        if (!obj)
                return -ENOENT;
 
-       if (mmap_type == I915_MMAP_TYPE_GTT &&
-           i915_gem_object_never_bind_ggtt(obj)) {
+       if (i915_gem_object_never_mmap(obj)) {
                err = -ENODEV;
                goto out;
        }
index 9c86f2dea947b415de4524718c174adbc30f5e44..e44a2f40b52030ff54b8635bbf1edf667a13890e 100644 (file)
@@ -194,9 +194,9 @@ i915_gem_object_is_proxy(const struct drm_i915_gem_object *obj)
 }
 
 static inline bool
-i915_gem_object_never_bind_ggtt(const struct drm_i915_gem_object *obj)
+i915_gem_object_never_mmap(const struct drm_i915_gem_object *obj)
 {
-       return i915_gem_object_type_has(obj, I915_GEM_OBJECT_NO_GGTT);
+       return i915_gem_object_type_has(obj, I915_GEM_OBJECT_NO_MMAP);
 }
 
 static inline bool
index c2174da35bb0fdf3890af589440be127676df876..a0b10bcd8d8acbd94e81f004a07428636d54bf7a 100644 (file)
@@ -34,7 +34,7 @@ struct drm_i915_gem_object_ops {
 #define I915_GEM_OBJECT_HAS_IOMEM      BIT(1)
 #define I915_GEM_OBJECT_IS_SHRINKABLE  BIT(2)
 #define I915_GEM_OBJECT_IS_PROXY       BIT(3)
-#define I915_GEM_OBJECT_NO_GGTT                BIT(4)
+#define I915_GEM_OBJECT_NO_MMAP                BIT(4)
 #define I915_GEM_OBJECT_ASYNC_CANCEL   BIT(5)
 
        /* Interface between the GEM object and its backing storage.
index a74d4ac6a39f43bb606daefe30cd6d9cc140fdfa..63ead7a2b64af90c565fc1dc27f4c1af84e7c7be 100644 (file)
@@ -704,7 +704,7 @@ i915_gem_userptr_dmabuf_export(struct drm_i915_gem_object *obj)
 static const struct drm_i915_gem_object_ops i915_gem_userptr_ops = {
        .flags = I915_GEM_OBJECT_HAS_STRUCT_PAGE |
                 I915_GEM_OBJECT_IS_SHRINKABLE |
-                I915_GEM_OBJECT_NO_GGTT |
+                I915_GEM_OBJECT_NO_MMAP |
                 I915_GEM_OBJECT_ASYNC_CANCEL,
        .get_pages = i915_gem_userptr_get_pages,
        .put_pages = i915_gem_userptr_put_pages,
index a712e60b016ac296ca512a1df2c4ba5321d037fa..d92cf966fa3ff357f32b938f915a280dfc10e253 100644 (file)
@@ -941,9 +941,6 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
        struct i915_vma *vma;
        int ret;
 
-       if (i915_gem_object_never_bind_ggtt(obj))
-               return ERR_PTR(-ENODEV);
-
        if (flags & PIN_MAPPABLE &&
            (!view || view->type == I915_GGTT_VIEW_NORMAL)) {
                /*