All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/userptr: Probe vma range before gup
@ 2017-12-15  9:27 Chris Wilson
  2017-12-15  9:43 ` Tvrtko Ursulin
                   ` (19 more replies)
  0 siblings, 20 replies; 25+ messages in thread
From: Chris Wilson @ 2017-12-15  9:27 UTC (permalink / raw)
  To: intel-gfx

We want to exclude any GGTT objects from being present on our internal
lists to avoid the deadlock we may run into with our requirement for
struct_mutex during invalidate. However, if the gup_fast fails, we put
the userptr onto the workqueue and mark it as active, so that we
remember to serialise the worker upon mmu_invalidate.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 40 +++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index 382a77a1097e..562b869dc750 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -598,6 +598,39 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	return ERR_PTR(-EAGAIN);
 }
 
+static int
+probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
+{
+	const unsigned long end = addr + len;
+	struct vm_area_struct *vma;
+	int ret = -EFAULT;
+
+	down_read(&mm->mmap_sem);
+	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
+		if (vma->vm_start > addr)
+			break;
+
+		/*
+		 * Exclude any VMA that is backed only by struct_page, i.e.
+		 * IO regions that include our own GGTT mmaps. We cannot handle
+		 * such ranges, as we may encounter deadlocks around our
+		 * struct_mutex on mmu_invalidate_range.
+		 */
+		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
+			break;
+
+		if (vma->vm_end >= end) {
+			ret = 0;
+			break;
+		}
+
+		addr = vma->vm_end;
+	}
+	up_read(&mm->mmap_sem);
+
+	return ret;
+}
+
 static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 {
 	const int num_pages = obj->base.size >> PAGE_SHIFT;
@@ -632,9 +665,12 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 			return -EAGAIN;
 	}
 
-	pvec = NULL;
-	pinned = 0;
+	/* Quickly exclude any invalid VMA */
+	pinned = probe_range(mm, obj->userptr.ptr, obj->base.size);
+	if (pinned)
+		return pinned;
 
+	pvec = NULL;
 	if (mm == current->mm) {
 		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
 				      GFP_KERNEL |
-- 
2.15.1

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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH] drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
@ 2017-12-15  9:43 ` Tvrtko Ursulin
  2017-12-15  9:46 ` Chris Wilson
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Tvrtko Ursulin @ 2017-12-15  9:43 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx


On 15/12/2017 09:27, Chris Wilson wrote:
> We want to exclude any GGTT objects from being present on our internal
> lists to avoid the deadlock we may run into with our requirement for
> struct_mutex during invalidate. However, if the gup_fast fails, we put
> the userptr onto the workqueue and mark it as active, so that we
> remember to serialise the worker upon mmu_invalidate.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_gem_userptr.c | 40 +++++++++++++++++++++++++++++++--
>   1 file changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
> index 382a77a1097e..562b869dc750 100644
> --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
> @@ -598,6 +598,39 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
>   	return ERR_PTR(-EAGAIN);
>   }
>   
> +static int
> +probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
> +{
> +	const unsigned long end = addr + len;
> +	struct vm_area_struct *vma;
> +	int ret = -EFAULT;
> +
> +	down_read(&mm->mmap_sem);
> +	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
> +		if (vma->vm_start > addr)
> +			break;
> +
> +		/*
> +		 * Exclude any VMA that is backed only by struct_page, i.e.
> +		 * IO regions that include our own GGTT mmaps. We cannot handle
> +		 * such ranges, as we may encounter deadlocks around our
> +		 * struct_mutex on mmu_invalidate_range.
> +		 */
> +		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
> +			break;
> +
> +		if (vma->vm_end >= end) {
> +			ret = 0;
> +			break;
> +		}
> +
> +		addr = vma->vm_end;
> +	}
> +	up_read(&mm->mmap_sem);
> +
> +	return ret;
> +}
> +
>   static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>   {
>   	const int num_pages = obj->base.size >> PAGE_SHIFT;
> @@ -632,9 +665,12 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>   			return -EAGAIN;
>   	}
>   
> -	pvec = NULL;
> -	pinned = 0;
> +	/* Quickly exclude any invalid VMA */
> +	pinned = probe_range(mm, obj->userptr.ptr, obj->base.size);
> +	if (pinned)
> +		return pinned;
>   
> +	pvec = NULL;
>   	if (mm == current->mm) {
>   		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
>   				      GFP_KERNEL |
> 

Okay as a band-aid, but open to exploitation, which I think was my issue 
last time you posted something similar? Anyways.. it's not worse so 
lesson learnt, of some sort.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
  2017-12-15  9:43 ` Tvrtko Ursulin
@ 2017-12-15  9:46 ` Chris Wilson
  2017-12-15  9:49 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Chris Wilson @ 2017-12-15  9:46 UTC (permalink / raw)
  To: intel-gfx; +Cc: Tvrtko

Quoting Chris Wilson (2017-12-15 09:27:27)
> We want to exclude any GGTT objects from being present on our internal
> lists to avoid the deadlock we may run into with our requirement for
> struct_mutex during invalidate. However, if the gup_fast fails, we put
> the userptr onto the workqueue and mark it as active, so that we
> remember to serialise the worker upon mmu_invalidate.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_userptr.c | 40 +++++++++++++++++++++++++++++++--
>  1 file changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
> index 382a77a1097e..562b869dc750 100644
> --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
> @@ -598,6 +598,39 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
>         return ERR_PTR(-EAGAIN);
>  }
>  
> +static int
> +probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
> +{
> +       const unsigned long end = addr + len;
> +       struct vm_area_struct *vma;
> +       int ret = -EFAULT;
> +
> +       down_read(&mm->mmap_sem);
> +       for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
> +               if (vma->vm_start > addr)
> +                       break;
> +
> +               /*
> +                * Exclude any VMA that is backed only by struct_page, i.e.
> +                * IO regions that include our own GGTT mmaps. We cannot handle
> +                * such ranges, as we may encounter deadlocks around our
> +                * struct_mutex on mmu_invalidate_range.
> +                */
> +               if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
> +                       break;
> +
> +               if (vma->vm_end >= end) {
> +                       ret = 0;
> +                       break;
> +               }
> +
> +               addr = vma->vm_end;
> +       }
> +       up_read(&mm->mmap_sem);
> +
> +       return ret;
> +}
> +
>  static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>  {
>         const int num_pages = obj->base.size >> PAGE_SHIFT;
> @@ -632,9 +665,12 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>                         return -EAGAIN;
>         }
>  
> -       pvec = NULL;
> -       pinned = 0;
> +       /* Quickly exclude any invalid VMA */
> +       pinned = probe_range(mm, obj->userptr.ptr, obj->base.size);
> +       if (pinned)
> +               return pinned;

There's a nasty race here. Actually the same race we have with the
interval_tree anyway, if we schedule then there's a gap before we add it
to the interval_tree, the state of the mm may have changed with us
noticing or invalidating the pages.

To close that race, we will have to add to active first. Let's see how
that looks.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
  2017-12-15  9:43 ` Tvrtko Ursulin
  2017-12-15  9:46 ` Chris Wilson
@ 2017-12-15  9:49 ` Patchwork
  2017-12-15  9:53 ` [PATCH v2] " Chris Wilson
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2017-12-15  9:49 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup
URL   : https://patchwork.freedesktop.org/series/35394/
State : success

== Summary ==

Series 35394v1 drm/i915/userptr: Probe vma range before gup
https://patchwork.freedesktop.org/api/1.0/series/35394/revisions/1/mbox/

Test debugfs_test:
        Subgroup read_all_entries:
                incomplete -> PASS       (fi-snb-2520m) fdo#103713
Test gem_sync:
        Subgroup basic-each:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-many-each:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-store-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-store-each:
                skip       -> PASS       (fi-blb-e6850)
Test gem_tiled_blits:
        Subgroup basic:
                skip       -> PASS       (fi-blb-e6850)
Test gem_tiled_fence_blits:
        Subgroup basic:
                skip       -> PASS       (fi-blb-e6850)
Test gem_wait:
        Subgroup basic-busy-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-wait-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-await-all:
                skip       -> PASS       (fi-blb-e6850)
Test kms_busy:
        Subgroup basic-flip-a:
                skip       -> PASS       (fi-blb-e6850)
                pass       -> DMESG-WARN (fi-elk-e7500) fdo#103989
        Subgroup basic-flip-b:
                skip       -> PASS       (fi-blb-e6850)
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-legacy:
                skip       -> PASS       (fi-blb-e6850)
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-a:
                pass       -> DMESG-WARN (fi-kbl-r) fdo#104172 +1

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#104172 https://bugs.freedesktop.org/show_bug.cgi?id=104172

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:440s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:439s
fi-blb-e6850     total:288  pass:222  dwarn:1   dfail:1   fail:0   skip:64  time:396s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:503s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:277s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:493s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:497s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:477s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:470s
fi-elk-e7500     total:224  pass:163  dwarn:14  dfail:1   fail:0   skip:45 
fi-gdg-551       total:288  pass:178  dwarn:1   dfail:0   fail:1   skip:108 time:264s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:530s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:407s
fi-hsw-4770r     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:415s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:391s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:473s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:428s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:483s
fi-kbl-7560u     total:288  pass:268  dwarn:1   dfail:0   fail:0   skip:19  time:518s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:467s
fi-kbl-r         total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:524s
fi-pnv-d510      total:288  pass:221  dwarn:1   dfail:0   fail:1   skip:65  time:593s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:451s
fi-skl-6600u     total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:540s
fi-skl-6700hq    total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:562s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:492s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:446s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:547s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:412s
Blacklisted hosts:
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:599s
fi-cnl-y         total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:626s

ad43db157c69bf7311ba5a0278f282796242f34a drm-tip: 2017y-12m-14d-20h-09m-53s UTC integration manifest
ea1835aad191 drm/i915/userptr: Probe vma range before gup

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7500/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v2] drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (2 preceding siblings ...)
  2017-12-15  9:49 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2017-12-15  9:53 ` Chris Wilson
  2017-12-15 10:06   ` Chris Wilson
  2017-12-15 10:09 ` [PATCH v3] " Chris Wilson
                   ` (15 subsequent siblings)
  19 siblings, 1 reply; 25+ messages in thread
From: Chris Wilson @ 2017-12-15  9:53 UTC (permalink / raw)
  To: intel-gfx

We want to exclude any GGTT objects from being present on our internal
lists to avoid the deadlock we may run into with our requirement for
struct_mutex during invalidate. However, if the gup_fast fails, we put
the userptr onto the workqueue and mark it as active, so that we
remember to serialise the worker upon mmu_invalidate.

v2: Hold mmap_sem to prevent modifications to the mm while we probe and
add ourselves to the interval-tree for notificiation.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 52 ++++++++++++++++++++++++++++++---
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index 382a77a1097e..71971020562a 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -598,6 +598,37 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	return ERR_PTR(-EAGAIN);
 }
 
+static int
+probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
+{
+	const unsigned long end = addr + len;
+	struct vm_area_struct *vma;
+	int ret = -EFAULT;
+
+	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
+		if (vma->vm_start > addr)
+			break;
+
+		/*
+		 * Exclude any VMA that is backed only by struct_page, i.e.
+		 * IO regions that include our own GGTT mmaps. We cannot handle
+		 * such ranges, as we may encounter deadlocks around our
+		 * struct_mutex on mmu_invalidate_range.
+		 */
+		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
+			break;
+
+		if (vma->vm_end >= end) {
+			ret = 0;
+			break;
+		}
+
+		addr = vma->vm_end;
+	}
+
+	return ret;
+}
+
 static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 {
 	const int num_pages = obj->base.size >> PAGE_SHIFT;
@@ -632,9 +663,17 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 			return -EAGAIN;
 	}
 
-	pvec = NULL;
-	pinned = 0;
+	/* Quickly exclude any invalid VMA */
+	down_read(&mm->mmap_sem);
+	pinned = probe_range(mm, obj->userptr.ptr, obj->base.size);
+	if (pinned)
+		goto err_mmap_sem;
+
+	pinned = __i915_gem_userptr_set_active(obj, true);
+	if (pinned)
+		goto err_mmap_sem;
 
+	pvec = NULL;
 	if (mm == current->mm) {
 		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
 				      GFP_KERNEL |
@@ -658,14 +697,19 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 		pages = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
 		active = !IS_ERR(pages);
 	}
-	if (active)
-		__i915_gem_userptr_set_active(obj, true);
+	if (!active)
+		__i915_gem_userptr_set_active(obj, false);
+	up_read(&mm->mmap_sem);
 
 	if (IS_ERR(pages))
 		release_pages(pvec, pinned);
 	kvfree(pvec);
 
 	return PTR_ERR_OR_ZERO(pages);
+
+err_mmap_sem:
+	up_read(&mm->mmap_sem);
+	return pinned;
 }
 
 static void
-- 
2.15.1

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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v2] drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:53 ` [PATCH v2] " Chris Wilson
@ 2017-12-15 10:06   ` Chris Wilson
  0 siblings, 0 replies; 25+ messages in thread
From: Chris Wilson @ 2017-12-15 10:06 UTC (permalink / raw)
  To: intel-gfx; +Cc: Tvrtko

Quoting Chris Wilson (2017-12-15 09:53:45)
> We want to exclude any GGTT objects from being present on our internal
> lists to avoid the deadlock we may run into with our requirement for
> struct_mutex during invalidate. However, if the gup_fast fails, we put
> the userptr onto the workqueue and mark it as active, so that we
> remember to serialise the worker upon mmu_invalidate.
> 
> v2: Hold mmap_sem to prevent modifications to the mm while we probe and
> add ourselves to the interval-tree for notificiation.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_userptr.c | 52 ++++++++++++++++++++++++++++++---
>  1 file changed, 48 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
> index 382a77a1097e..71971020562a 100644
> --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
> @@ -598,6 +598,37 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
>         return ERR_PTR(-EAGAIN);
>  }
>  
> +static int
> +probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
> +{
> +       const unsigned long end = addr + len;
> +       struct vm_area_struct *vma;
> +       int ret = -EFAULT;
> +
> +       for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
> +               if (vma->vm_start > addr)
> +                       break;
> +
> +               /*
> +                * Exclude any VMA that is backed only by struct_page, i.e.
> +                * IO regions that include our own GGTT mmaps. We cannot handle
> +                * such ranges, as we may encounter deadlocks around our
> +                * struct_mutex on mmu_invalidate_range.
> +                */
> +               if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
> +                       break;
> +
> +               if (vma->vm_end >= end) {
> +                       ret = 0;
> +                       break;
> +               }
> +
> +               addr = vma->vm_end;
> +       }
> +
> +       return ret;
> +}
> +
>  static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>  {
>         const int num_pages = obj->base.size >> PAGE_SHIFT;
> @@ -632,9 +663,17 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>                         return -EAGAIN;
>         }
>  
> -       pvec = NULL;
> -       pinned = 0;
> +       /* Quickly exclude any invalid VMA */
> +       down_read(&mm->mmap_sem);
> +       pinned = probe_range(mm, obj->userptr.ptr, obj->base.size);
> +       if (pinned)
> +               goto err_mmap_sem;
> +
> +       pinned = __i915_gem_userptr_set_active(obj, true);
> +       if (pinned)
> +               goto err_mmap_sem;
>  
> +       pvec = NULL;
>         if (mm == current->mm) {
>                 pvec = kvmalloc_array(num_pages, sizeof(struct page *),
>                                       GFP_KERNEL |
> @@ -658,14 +697,19 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>                 pages = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
>                 active = !IS_ERR(pages);
>         }
> -       if (active)
> -               __i915_gem_userptr_set_active(obj, true);
> +       if (!active)
> +               __i915_gem_userptr_set_active(obj, false);
> +       up_read(&mm->mmap_sem);

Otoh, if we are holding mmap_sem all this time, we don't need to call
set_active twice as we should be serialized with mmu-invalidate.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v3] drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (3 preceding siblings ...)
  2017-12-15  9:53 ` [PATCH v2] " Chris Wilson
@ 2017-12-15 10:09 ` Chris Wilson
  2017-12-15 10:49   ` Chris Wilson
  2017-12-15 10:33 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev3) Patchwork
                   ` (14 subsequent siblings)
  19 siblings, 1 reply; 25+ messages in thread
From: Chris Wilson @ 2017-12-15 10:09 UTC (permalink / raw)
  To: intel-gfx

We want to exclude any GGTT objects from being present on our internal
lists to avoid the deadlock we may run into with our requirement for
struct_mutex during invalidate. However, if the gup_fast fails, we put
the userptr onto the workqueue and mark it as active, so that we
remember to serialise the worker upon mmu_invalidate.

v2: Hold mmap_sem to prevent modifications to the mm while we probe and
add ourselves to the interval-tree for notificiation.
v3: Rely on mmap_sem for a simpler patch.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 42 +++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index 382a77a1097e..f879c76e46ee 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -598,6 +598,37 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	return ERR_PTR(-EAGAIN);
 }
 
+static int
+probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
+{
+	const unsigned long end = addr + len;
+	struct vm_area_struct *vma;
+	int ret = -EFAULT;
+
+	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
+		if (vma->vm_start > addr)
+			break;
+
+		/*
+		 * Exclude any VMA that is backed only by struct_page, i.e.
+		 * IO regions that include our own GGTT mmaps. We cannot handle
+		 * such ranges, as we may encounter deadlocks around our
+		 * struct_mutex on mmu_invalidate_range.
+		 */
+		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
+			break;
+
+		if (vma->vm_end >= end) {
+			ret = 0;
+			break;
+		}
+
+		addr = vma->vm_end;
+	}
+
+	return ret;
+}
+
 static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 {
 	const int num_pages = obj->base.size >> PAGE_SHIFT;
@@ -632,9 +663,15 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 			return -EAGAIN;
 	}
 
-	pvec = NULL;
-	pinned = 0;
+	/* Quickly exclude any invalid VMA */
+	down_read(&mm->mmap_sem);
+	pinned = probe_range(mm, obj->userptr.ptr, obj->base.size);
+	if (pinned) {
+		up_read(&mm->mmap_sem);
+		return pinned;
+	}
 
+	pvec = NULL;
 	if (mm == current->mm) {
 		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
 				      GFP_KERNEL |
@@ -660,6 +697,7 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 	}
 	if (active)
 		__i915_gem_userptr_set_active(obj, true);
+	up_read(&mm->mmap_sem);
 
 	if (IS_ERR(pages))
 		release_pages(pvec, pinned);
-- 
2.15.1

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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev3)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (4 preceding siblings ...)
  2017-12-15 10:09 ` [PATCH v3] " Chris Wilson
@ 2017-12-15 10:33 ` Patchwork
  2017-12-15 10:38 ` ✗ Fi.CI.IGT: warning for drm/i915/userptr: Probe vma range before gup Patchwork
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2017-12-15 10:33 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev3)
URL   : https://patchwork.freedesktop.org/series/35394/
State : success

== Summary ==

Series 35394v3 drm/i915/userptr: Probe vma range before gup
https://patchwork.freedesktop.org/api/1.0/series/35394/revisions/3/mbox/

Test debugfs_test:
        Subgroup read_all_entries:
                incomplete -> PASS       (fi-snb-2520m) fdo#103713 +1
Test gem_mmap_gtt:
        Subgroup basic-small-bo-tiledx:
                fail       -> PASS       (fi-gdg-551) fdo#102575
Test gem_sync:
        Subgroup basic-each:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-many-each:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-store-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-store-each:
                skip       -> PASS       (fi-blb-e6850)
Test gem_tiled_blits:
        Subgroup basic:
                skip       -> PASS       (fi-blb-e6850)
Test gem_tiled_fence_blits:
        Subgroup basic:
                skip       -> PASS       (fi-blb-e6850)
Test gem_wait:
        Subgroup basic-busy-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-wait-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-await-all:
                skip       -> PASS       (fi-blb-e6850)
Test kms_busy:
        Subgroup basic-flip-a:
                skip       -> PASS       (fi-blb-e6850)
                pass       -> DMESG-WARN (fi-elk-e7500) fdo#103989
        Subgroup basic-flip-b:
                skip       -> PASS       (fi-blb-e6850)
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-legacy:
                skip       -> PASS       (fi-blb-e6850)
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-kbl-r) fdo#104172 +1

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#104172 https://bugs.freedesktop.org/show_bug.cgi?id=104172

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:435s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:439s
fi-blb-e6850     total:288  pass:222  dwarn:1   dfail:1   fail:0   skip:64  time:391s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:504s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:278s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:492s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:498s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:493s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:472s
fi-elk-e7500     total:224  pass:163  dwarn:14  dfail:1   fail:0   skip:45 
fi-gdg-551       total:288  pass:179  dwarn:1   dfail:0   fail:0   skip:108 time:264s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:533s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:409s
fi-hsw-4770r     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:419s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:393s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:471s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:427s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:481s
fi-kbl-7560u     total:288  pass:268  dwarn:1   dfail:0   fail:0   skip:19  time:520s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:469s
fi-kbl-r         total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:520s
fi-pnv-d510      total:288  pass:221  dwarn:1   dfail:0   fail:1   skip:65  time:591s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:448s
fi-skl-6600u     total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:534s
fi-skl-6700hq    total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:558s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:486s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:448s
fi-snb-2520m     total:245  pass:211  dwarn:0   dfail:0   fail:0   skip:33 
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:412s
Blacklisted hosts:
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:591s
fi-cnl-y         total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:622s
fi-glk-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:484s

ad43db157c69bf7311ba5a0278f282796242f34a drm-tip: 2017y-12m-14d-20h-09m-53s UTC integration manifest
e4c281e35b1b drm/i915/userptr: Probe vma range before gup

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7501/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* ✗ Fi.CI.IGT: warning for drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (5 preceding siblings ...)
  2017-12-15 10:33 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev3) Patchwork
@ 2017-12-15 10:38 ` Patchwork
  2017-12-15 11:20 ` [PATCH v4] " Chris Wilson
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2017-12-15 10:38 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup
URL   : https://patchwork.freedesktop.org/series/35394/
State : warning

== Summary ==

Test gem_userptr_blits:
        Subgroup map-fixed-invalidate-busy-gup:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup sync-unmap-cycles:
                pass       -> DMESG-WARN (shard-snb)
        Subgroup sync-unmap-after-close:
                pass       -> DMESG-WARN (shard-snb)
        Subgroup invalid-null-pointer:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup coherency-sync:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup process-exit-gtt-busy:
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup map-fixed-invalidate-busy:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
Test drv_selftest:
        Subgroup mock_sanitycheck:
                pass       -> DMESG-WARN (shard-snb) fdo#102707 +1
Test pm_rpm:
        Subgroup cursor-dpms:
                pass       -> SKIP       (shard-hsw)
Test gem_tiled_swapping:
        Subgroup non-threaded:
                dmesg-warn -> PASS       (shard-hsw) fdo#104218 +1
Test kms_frontbuffer_tracking:
        Subgroup fbc-1p-offscren-pri-shrfb-draw-render:
                fail       -> PASS       (shard-snb) fdo#101623
Test kms_flip:
        Subgroup vblank-vs-suspend:
                incomplete -> PASS       (shard-hsw) fdo#103375
        Subgroup plain-flip-ts-check-interruptible:
                pass       -> FAIL       (shard-hsw) fdo#100368

fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707
fdo#104218 https://bugs.freedesktop.org/show_bug.cgi?id=104218
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368

shard-hsw        total:2712 pass:1528 dwarn:8   dfail:0   fail:11  skip:1165 time:9164s
shard-snb        total:2712 pass:1302 dwarn:8   dfail:0   fail:11  skip:1391 time:7727s
Blacklisted hosts:
shard-apl        total:2712 pass:1677 dwarn:7   dfail:0   fail:26  skip:1001 time:12890s
shard-kbl        total:2636 pass:1736 dwarn:15  dfail:0   fail:30  skip:855 time:10356s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7500/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3] drm/i915/userptr: Probe vma range before gup
  2017-12-15 10:09 ` [PATCH v3] " Chris Wilson
@ 2017-12-15 10:49   ` Chris Wilson
  0 siblings, 0 replies; 25+ messages in thread
From: Chris Wilson @ 2017-12-15 10:49 UTC (permalink / raw)
  To: intel-gfx; +Cc: Tvrtko

Quoting Chris Wilson (2017-12-15 10:09:02)
> We want to exclude any GGTT objects from being present on our internal
> lists to avoid the deadlock we may run into with our requirement for
> struct_mutex during invalidate. However, if the gup_fast fails, we put
> the userptr onto the workqueue and mark it as active, so that we
> remember to serialise the worker upon mmu_invalidate.
> 
> v2: Hold mmap_sem to prevent modifications to the mm while we probe and
> add ourselves to the interval-tree for notificiation.
> v3: Rely on mmap_sem for a simpler patch.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_userptr.c | 42 +++++++++++++++++++++++++++++++--
>  1 file changed, 40 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
> index 382a77a1097e..f879c76e46ee 100644
> --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
> @@ -598,6 +598,37 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
>         return ERR_PTR(-EAGAIN);
>  }
>  
> +static int
> +probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
> +{
> +       const unsigned long end = addr + len;
> +       struct vm_area_struct *vma;
> +       int ret = -EFAULT;
> +
> +       for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
> +               if (vma->vm_start > addr)
> +                       break;
> +
> +               /*
> +                * Exclude any VMA that is backed only by struct_page, i.e.
> +                * IO regions that include our own GGTT mmaps. We cannot handle
> +                * such ranges, as we may encounter deadlocks around our
> +                * struct_mutex on mmu_invalidate_range.
> +                */
> +               if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
> +                       break;
> +
> +               if (vma->vm_end >= end) {
> +                       ret = 0;
> +                       break;
> +               }
> +
> +               addr = vma->vm_end;
> +       }
> +
> +       return ret;
> +}
> +
>  static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>  {
>         const int num_pages = obj->base.size >> PAGE_SHIFT;
> @@ -632,9 +663,15 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>                         return -EAGAIN;
>         }
>  
> -       pvec = NULL;
> -       pinned = 0;
> +       /* Quickly exclude any invalid VMA */
> +       down_read(&mm->mmap_sem);

Regardless, mmap_sem is not allowed here, as we may be underneath
struct_mutex and a mmap_sem from a pagefault.

Please look the other way as I investigate nesting...
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v4] drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (6 preceding siblings ...)
  2017-12-15 10:38 ` ✗ Fi.CI.IGT: warning for drm/i915/userptr: Probe vma range before gup Patchwork
@ 2017-12-15 11:20 ` Chris Wilson
  2017-12-15 11:57 ` ✗ Fi.CI.IGT: failure for drm/i915/userptr: Probe vma range before gup (rev3) Patchwork
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Chris Wilson @ 2017-12-15 11:20 UTC (permalink / raw)
  To: intel-gfx

We want to exclude any GGTT objects from being present on our internal
lists to avoid the deadlock we may run into with our requirement for
struct_mutex during invalidate. However, if the gup_fast fails, we put
the userptr onto the workqueue and mark it as active, so that we
remember to serialise the worker upon mmu_invalidate.

v2: Hold mmap_sem to prevent modifications to the mm while we probe and
add ourselves to the interval-tree for notificiation.
v3: Rely on mmap_sem for a simpler patch.
v4: Mark up the mmap_sem nesting

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 55 +++++++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index 382a77a1097e..e6280bb4168e 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -598,13 +598,43 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	return ERR_PTR(-EAGAIN);
 }
 
+static int
+probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
+{
+	const unsigned long end = addr + len;
+	struct vm_area_struct *vma;
+	int ret = -EFAULT;
+
+	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
+		if (vma->vm_start > addr)
+			break;
+
+		/*
+		 * Exclude any VMA that is backed only by struct_page, i.e.
+		 * IO regions that include our own GGTT mmaps. We cannot handle
+		 * such ranges, as we may encounter deadlocks around our
+		 * struct_mutex on mmu_invalidate_range.
+		 */
+		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
+			break;
+
+		if (vma->vm_end >= end) {
+			ret = 0;
+			break;
+		}
+
+		addr = vma->vm_end;
+	}
+
+	return ret;
+}
+
 static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 {
 	const int num_pages = obj->base.size >> PAGE_SHIFT;
 	struct mm_struct *mm = obj->userptr.mm->mm;
 	struct page **pvec;
 	struct sg_table *pages;
-	bool active;
 	int pinned;
 
 	/* If userspace should engineer that these pages are replaced in
@@ -634,7 +664,6 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 
 	pvec = NULL;
 	pinned = 0;
-
 	if (mm == current->mm) {
 		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
 				      GFP_KERNEL |
@@ -647,19 +676,25 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 						       pvec);
 	}
 
-	active = false;
+	down_read_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);
 	if (pinned < 0) {
 		pages = ERR_PTR(pinned);
 		pinned = 0;
-	} else if (pinned < num_pages) {
-		pages = __i915_gem_userptr_get_pages_schedule(obj);
-		active = pages == ERR_PTR(-EAGAIN);
+	} else if (pinned < num_pages &&
+		   probe_range(mm, obj->userptr.ptr, obj->base.size)) {
+		pages = ERR_PTR(-EFAULT);
+	} else  if (__i915_gem_userptr_set_active(obj, true)) {
+		pages = ERR_PTR(-EAGAIN);
 	} else {
-		pages = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
-		active = !IS_ERR(pages);
+		if (pinned < num_pages)
+			pages = __i915_gem_userptr_get_pages_schedule(obj);
+		else
+			pages = __i915_gem_userptr_alloc_pages(obj,
+							       pvec, num_pages);
+		if (IS_ERR(pages))
+			__i915_gem_userptr_set_active(obj, false);
 	}
-	if (active)
-		__i915_gem_userptr_set_active(obj, true);
+	up_read(&mm->mmap_sem);
 
 	if (IS_ERR(pages))
 		release_pages(pvec, pinned);
-- 
2.15.1

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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* ✗ Fi.CI.IGT: failure for drm/i915/userptr: Probe vma range before gup (rev3)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (7 preceding siblings ...)
  2017-12-15 11:20 ` [PATCH v4] " Chris Wilson
@ 2017-12-15 11:57 ` Patchwork
  2017-12-15 12:22 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev4) Patchwork
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2017-12-15 11:57 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev3)
URL   : https://patchwork.freedesktop.org/series/35394/
State : failure

== Summary ==

Test kms_plane:
        Subgroup plane-panning-bottom-right-suspend-pipe-b-planes:
                pass       -> DMESG-WARN (shard-hsw)
Test gem_userptr_blits:
        Subgroup invalid-null-pointer:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup dmabuf-sync:
                pass       -> DMESG-WARN (shard-snb)
        Subgroup coherency-sync:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup sync-unmap-cycles:
                pass       -> DMESG-WARN (shard-snb)
        Subgroup map-fixed-invalidate-busy:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup coherency-unsync:
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup map-fixed-invalidate-busy-gup:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
Test gem_tiled_swapping:
        Subgroup non-threaded:
                dmesg-warn -> INCOMPLETE (shard-hsw) fdo#104218
Test kms_frontbuffer_tracking:
        Subgroup fbc-1p-offscren-pri-shrfb-draw-render:
                fail       -> PASS       (shard-snb) fdo#101623
Test kms_flip:
        Subgroup vblank-vs-suspend:
                incomplete -> PASS       (shard-hsw) fdo#103375
Test gem_exec_reloc:
        Subgroup basic-range:
                pass       -> INCOMPLETE (shard-snb)
Test kms_cursor_legacy:
        Subgroup cursora-vs-flipa-toggle:
                pass       -> INCOMPLETE (shard-snb)

fdo#104218 https://bugs.freedesktop.org/show_bug.cgi?id=104218
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375

shard-hsw        total:2645 pass:1488 dwarn:7   dfail:0   fail:10  skip:1139 time:9010s
shard-snb        total:2605 pass:1246 dwarn:7   dfail:0   fail:11  skip:1339 time:7186s
Blacklisted hosts:
shard-apl        total:2645 pass:1628 dwarn:9   dfail:0   fail:28  skip:979 time:12581s
shard-kbl        total:2712 pass:1785 dwarn:17  dfail:1   fail:30  skip:879 time:10996s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7501/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev4)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (8 preceding siblings ...)
  2017-12-15 11:57 ` ✗ Fi.CI.IGT: failure for drm/i915/userptr: Probe vma range before gup (rev3) Patchwork
@ 2017-12-15 12:22 ` Patchwork
  2017-12-15 14:33 ` ✗ Fi.CI.IGT: failure " Patchwork
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2017-12-15 12:22 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev4)
URL   : https://patchwork.freedesktop.org/series/35394/
State : success

== Summary ==

Series 35394v4 drm/i915/userptr: Probe vma range before gup
https://patchwork.freedesktop.org/api/1.0/series/35394/revisions/4/mbox/

Test debugfs_test:
        Subgroup read_all_entries:
                dmesg-fail -> DMESG-WARN (fi-elk-e7500) fdo#103989 +1
                incomplete -> PASS       (fi-snb-2520m) fdo#103713
Test gem_mmap_gtt:
        Subgroup basic-small-bo-tiledx:
                fail       -> PASS       (fi-gdg-551) fdo#102575
Test gem_sync:
        Subgroup basic-each:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-many-each:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-store-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-store-each:
                skip       -> PASS       (fi-blb-e6850)
Test gem_tiled_blits:
        Subgroup basic:
                skip       -> PASS       (fi-blb-e6850)
Test gem_tiled_fence_blits:
        Subgroup basic:
                skip       -> PASS       (fi-blb-e6850)
Test gem_wait:
        Subgroup basic-busy-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-wait-all:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-await-all:
                skip       -> PASS       (fi-blb-e6850)
Test kms_busy:
        Subgroup basic-flip-a:
                skip       -> PASS       (fi-blb-e6850)
        Subgroup basic-flip-b:
                skip       -> PASS       (fi-blb-e6850)
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-legacy:
                skip       -> PASS       (fi-blb-e6850)
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-a:
                pass       -> DMESG-WARN (fi-kbl-r) fdo#104172 +1

fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#104172 https://bugs.freedesktop.org/show_bug.cgi?id=104172

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:433s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:439s
fi-blb-e6850     total:288  pass:222  dwarn:1   dfail:1   fail:0   skip:64  time:399s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:513s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:279s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:493s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:502s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:490s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:477s
fi-elk-e7500     total:224  pass:163  dwarn:15  dfail:0   fail:0   skip:45 
fi-gdg-551       total:288  pass:179  dwarn:1   dfail:0   fail:0   skip:108 time:266s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:535s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:405s
fi-hsw-4770r     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:414s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:392s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:479s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:431s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:479s
fi-kbl-7560u     total:288  pass:268  dwarn:1   dfail:0   fail:0   skip:19  time:523s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:470s
fi-kbl-r         total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:525s
fi-pnv-d510      total:288  pass:221  dwarn:1   dfail:0   fail:1   skip:65  time:588s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:446s
fi-skl-6600u     total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:534s
fi-skl-6700hq    total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:557s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:490s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:442s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:544s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:418s
Blacklisted hosts:
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:596s
fi-cnl-y         total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:612s
fi-glk-dsi       total:288  pass:186  dwarn:1   dfail:4   fail:0   skip:97  time:397s

ad43db157c69bf7311ba5a0278f282796242f34a drm-tip: 2017y-12m-14d-20h-09m-53s UTC integration manifest
dad3b69f5451 drm/i915/userptr: Probe vma range before gup

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7504/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* ✗ Fi.CI.IGT: failure for drm/i915/userptr: Probe vma range before gup (rev4)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (9 preceding siblings ...)
  2017-12-15 12:22 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev4) Patchwork
@ 2017-12-15 14:33 ` Patchwork
  2017-12-15 14:48 ` [PATCH v5] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2017-12-15 14:33 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev4)
URL   : https://patchwork.freedesktop.org/series/35394/
State : failure

== Summary ==

Test gem_userptr_blits:
        Subgroup map-fixed-invalidate-overlap-busy-gup:
                pass       -> FAIL       (shard-snb)
                pass       -> FAIL       (shard-hsw)
        Subgroup map-fixed-invalidate-gup:
                pass       -> FAIL       (shard-snb)
                pass       -> FAIL       (shard-hsw) fdo#104209
        Subgroup sync-unmap-cycles:
                pass       -> FAIL       (shard-snb)
                pass       -> FAIL       (shard-hsw)
        Subgroup map-fixed-invalidate-overlap-gup:
                pass       -> FAIL       (shard-snb)
                pass       -> FAIL       (shard-hsw)
        Subgroup sync-unmap:
                pass       -> FAIL       (shard-snb)
                pass       -> FAIL       (shard-hsw)
        Subgroup map-fixed-invalidate-busy-gup:
                pass       -> FAIL       (shard-snb)
                pass       -> FAIL       (shard-hsw)
Test kms_flip:
        Subgroup vblank-vs-suspend:
                incomplete -> PASS       (shard-hsw) fdo#103375
        Subgroup vblank-vs-dpms-suspend:
                pass       -> INCOMPLETE (shard-hsw) fdo#103540
Test gem_tiled_swapping:
        Subgroup non-threaded:
                pass       -> INCOMPLETE (shard-snb) fdo#104218 +1
Test kms_frontbuffer_tracking:
        Subgroup fbc-1p-offscren-pri-shrfb-draw-render:
                fail       -> PASS       (shard-snb) fdo#101623 +1
Test gem_eio:
        Subgroup in-flight-contexts:
                pass       -> DMESG-WARN (shard-snb) fdo#104058

fdo#104209 https://bugs.freedesktop.org/show_bug.cgi?id=104209
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#104218 https://bugs.freedesktop.org/show_bug.cgi?id=104218
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#104058 https://bugs.freedesktop.org/show_bug.cgi?id=104058

shard-hsw        total:2603 pass:1464 dwarn:1   dfail:0   fail:16  skip:1120 time:8957s
shard-snb        total:2645 pass:1265 dwarn:2   dfail:0   fail:18  skip:1359 time:7873s
Blacklisted hosts:
shard-kbl        total:2645 pass:1749 dwarn:1   dfail:0   fail:38  skip:856 time:10821s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7504/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v5] drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (10 preceding siblings ...)
  2017-12-15 14:33 ` ✗ Fi.CI.IGT: failure " Patchwork
@ 2017-12-15 14:48 ` Chris Wilson
  2017-12-18 13:17   ` Tvrtko Ursulin
  2017-12-15 15:36 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev5) Patchwork
                   ` (7 subsequent siblings)
  19 siblings, 1 reply; 25+ messages in thread
From: Chris Wilson @ 2017-12-15 14:48 UTC (permalink / raw)
  To: intel-gfx

We want to exclude any GGTT objects from being present on our internal
lists to avoid the deadlock we may run into with our requirement for
struct_mutex during invalidate. However, if the gup_fast fails, we put
the userptr onto the workqueue and mark it as active, so that we
remember to serialise the worker upon mmu_invalidate.

v2: Hold mmap_sem to prevent modifications to the mm while we probe and
add ourselves to the interval-tree for notificiation.
v3: Rely on mmap_sem for a simpler patch.
v4: Mark up the mmap_sem nesting
v5: Don't deactivate on -EAGAIN as that means the worker is queued

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 55 +++++++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index 382a77a1097e..b16b8e226e40 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -598,13 +598,43 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	return ERR_PTR(-EAGAIN);
 }
 
+static int
+probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
+{
+	const unsigned long end = addr + len;
+	struct vm_area_struct *vma;
+	int ret = -EFAULT;
+
+	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
+		if (vma->vm_start > addr)
+			break;
+
+		/*
+		 * Exclude any VMA that is backed only by struct_page, i.e.
+		 * IO regions that include our own GGTT mmaps. We cannot handle
+		 * such ranges, as we may encounter deadlocks around our
+		 * struct_mutex on mmu_invalidate_range.
+		 */
+		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
+			break;
+
+		if (vma->vm_end >= end) {
+			ret = 0;
+			break;
+		}
+
+		addr = vma->vm_end;
+	}
+
+	return ret;
+}
+
 static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 {
 	const int num_pages = obj->base.size >> PAGE_SHIFT;
 	struct mm_struct *mm = obj->userptr.mm->mm;
 	struct page **pvec;
 	struct sg_table *pages;
-	bool active;
 	int pinned;
 
 	/* If userspace should engineer that these pages are replaced in
@@ -634,7 +664,6 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 
 	pvec = NULL;
 	pinned = 0;
-
 	if (mm == current->mm) {
 		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
 				      GFP_KERNEL |
@@ -647,19 +676,25 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 						       pvec);
 	}
 
-	active = false;
+	down_read_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);
 	if (pinned < 0) {
 		pages = ERR_PTR(pinned);
 		pinned = 0;
-	} else if (pinned < num_pages) {
-		pages = __i915_gem_userptr_get_pages_schedule(obj);
-		active = pages == ERR_PTR(-EAGAIN);
+	} else if (pinned < num_pages &&
+		   probe_range(mm, obj->userptr.ptr, obj->base.size)) {
+		pages = ERR_PTR(-EFAULT);
+	} else  if (__i915_gem_userptr_set_active(obj, true)) {
+		pages = ERR_PTR(-EAGAIN);
 	} else {
-		pages = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
-		active = !IS_ERR(pages);
+		if (pinned < num_pages)
+			pages = __i915_gem_userptr_get_pages_schedule(obj);
+		else
+			pages = __i915_gem_userptr_alloc_pages(obj,
+							       pvec, num_pages);
+		if (IS_ERR(pages) && pages != ERR_PTR(-EAGAIN))
+			__i915_gem_userptr_set_active(obj, false);
 	}
-	if (active)
-		__i915_gem_userptr_set_active(obj, true);
+	up_read(&mm->mmap_sem);
 
 	if (IS_ERR(pages))
 		release_pages(pvec, pinned);
-- 
2.15.1

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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev5)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (11 preceding siblings ...)
  2017-12-15 14:48 ` [PATCH v5] drm/i915/userptr: Probe vma range before gup Chris Wilson
@ 2017-12-15 15:36 ` Patchwork
  2017-12-15 18:09 ` ✓ Fi.CI.IGT: " Patchwork
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2017-12-15 15:36 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev5)
URL   : https://patchwork.freedesktop.org/series/35394/
State : success

== Summary ==

Series 35394v5 drm/i915/userptr: Probe vma range before gup
https://patchwork.freedesktop.org/api/1.0/series/35394/revisions/5/mbox/

Test debugfs_test:
        Subgroup read_all_entries:
                dmesg-fail -> DMESG-WARN (fi-elk-e7500) fdo#103989
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713
Test kms_psr_sink_crc:
        Subgroup psr_basic:
                pass       -> DMESG-WARN (fi-skl-6700hq) fdo#101144

fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#101144 https://bugs.freedesktop.org/show_bug.cgi?id=101144

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:436s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:439s
fi-blb-e6850     total:288  pass:222  dwarn:1   dfail:0   fail:1   skip:64  time:391s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:507s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:279s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:496s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:497s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:478s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:485s
fi-elk-e7500     total:224  pass:163  dwarn:15  dfail:0   fail:0   skip:45 
fi-gdg-551       total:288  pass:178  dwarn:1   dfail:0   fail:1   skip:108 time:265s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:536s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:404s
fi-hsw-4770r     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:413s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:395s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:478s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:425s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:479s
fi-kbl-7560u     total:288  pass:268  dwarn:1   dfail:0   fail:0   skip:19  time:521s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:465s
fi-pnv-d510      total:288  pass:221  dwarn:1   dfail:0   fail:1   skip:65  time:583s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:446s
fi-skl-6600u     total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:532s
fi-skl-6700hq    total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:559s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:488s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:450s
fi-snb-2520m     total:3    pass:2    dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:413s
Blacklisted hosts:
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:585s
fi-cnl-y         total:216  pass:195  dwarn:0   dfail:0   fail:0   skip:20 
fi-glk-dsi       total:195  pass:123  dwarn:0   dfail:1   fail:0   skip:70 
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:504s

d2a96c2d31af5cf964f9bb9b9c2cb453f6194954 drm-tip: 2017y-12m-15d-13h-58m-44s UTC integration manifest
066961b7b6fa drm/i915/userptr: Probe vma range before gup

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7508/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* ✓ Fi.CI.IGT: success for drm/i915/userptr: Probe vma range before gup (rev5)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (12 preceding siblings ...)
  2017-12-15 15:36 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev5) Patchwork
@ 2017-12-15 18:09 ` Patchwork
  2018-02-08 18:02 ` [PATCH v6] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2017-12-15 18:09 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev5)
URL   : https://patchwork.freedesktop.org/series/35394/
State : success

== Summary ==

Test kms_frontbuffer_tracking:
        Subgroup fbc-suspend:
                pass       -> INCOMPLETE (shard-hsw) fdo#103540 +2
        Subgroup fbc-1p-offscren-pri-shrfb-draw-blt:
                fail       -> PASS       (shard-snb) fdo#101623
Test gem_softpin:
        Subgroup noreloc-s3:
                pass       -> SKIP       (shard-snb) fdo#102365 +1
Test gem_eio:
        Subgroup in-flight-contexts:
                dmesg-warn -> PASS       (shard-snb) fdo#104058

fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#104058 https://bugs.freedesktop.org/show_bug.cgi?id=104058

shard-hsw        total:2658 pass:1508 dwarn:1   dfail:0   fail:10  skip:1138 time:9232s
shard-snb        total:2712 pass:1306 dwarn:1   dfail:0   fail:13  skip:1392 time:7879s
Blacklisted hosts:
shard-apl        total:2712 pass:1685 dwarn:1   dfail:0   fail:24  skip:1001 time:13867s
shard-kbl        total:2712 pass:1804 dwarn:1   dfail:0   fail:28  skip:879 time:11010s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7508/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v5] drm/i915/userptr: Probe vma range before gup
  2017-12-15 14:48 ` [PATCH v5] drm/i915/userptr: Probe vma range before gup Chris Wilson
@ 2017-12-18 13:17   ` Tvrtko Ursulin
  0 siblings, 0 replies; 25+ messages in thread
From: Tvrtko Ursulin @ 2017-12-18 13:17 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx


On 15/12/2017 14:48, Chris Wilson wrote:
> We want to exclude any GGTT objects from being present on our internal
> lists to avoid the deadlock we may run into with our requirement for
> struct_mutex during invalidate. However, if the gup_fast fails, we put
> the userptr onto the workqueue and mark it as active, so that we
> remember to serialise the worker upon mmu_invalidate.
> 
> v2: Hold mmap_sem to prevent modifications to the mm while we probe and
> add ourselves to the interval-tree for notificiation.
> v3: Rely on mmap_sem for a simpler patch.
> v4: Mark up the mmap_sem nesting
> v5: Don't deactivate on -EAGAIN as that means the worker is queued
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_gem_userptr.c | 55 +++++++++++++++++++++++++++------
>   1 file changed, 45 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
> index 382a77a1097e..b16b8e226e40 100644
> --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
> @@ -598,13 +598,43 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
>   	return ERR_PTR(-EAGAIN);
>   }
>   
> +static int
> +probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
> +{
> +	const unsigned long end = addr + len;
> +	struct vm_area_struct *vma;
> +	int ret = -EFAULT;
> +
> +	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
> +		if (vma->vm_start > addr)
> +			break;
> +
> +		/*
> +		 * Exclude any VMA that is backed only by struct_page, i.e.
> +		 * IO regions that include our own GGTT mmaps. We cannot handle
> +		 * such ranges, as we may encounter deadlocks around our
> +		 * struct_mutex on mmu_invalidate_range.
> +		 */
> +		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
> +			break;
> +
> +		if (vma->vm_end >= end) {
> +			ret = 0;
> +			break;
> +		}
> +
> +		addr = vma->vm_end;
> +	}
> +
> +	return ret;
> +}
> +
>   static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>   {
>   	const int num_pages = obj->base.size >> PAGE_SHIFT;
>   	struct mm_struct *mm = obj->userptr.mm->mm;
>   	struct page **pvec;
>   	struct sg_table *pages;
> -	bool active;
>   	int pinned;
>   
>   	/* If userspace should engineer that these pages are replaced in
> @@ -634,7 +664,6 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>   
>   	pvec = NULL;
>   	pinned = 0;
> -
>   	if (mm == current->mm) {
>   		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
>   				      GFP_KERNEL |
> @@ -647,19 +676,25 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
>   						       pvec);
>   	}
>   
> -	active = false;
> +	down_read_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);

Big fat comment here? Something about the gem fault path?

>   	if (pinned < 0) {
>   		pages = ERR_PTR(pinned);
>   		pinned = 0;
> -	} else if (pinned < num_pages) {
> -		pages = __i915_gem_userptr_get_pages_schedule(obj);
> -		active = pages == ERR_PTR(-EAGAIN);
> +	} else if (pinned < num_pages &&
> +		   probe_range(mm, obj->userptr.ptr, obj->base.size)) {

Keep going back to remind on the return value semantics. Rename to 
range_invalid or something?

> +		pages = ERR_PTR(-EFAULT);
> +	} else  if (__i915_gem_userptr_set_active(obj, true)) {

Isn't this the normal path now, I mean the path where pinned == 
num_pages? So it sets the active to true, which is a bit evil to do in 
the condition check, and then fall through to the else block to finish 
the job.

I'll see if I can come up with something perhaps more readable in the 
background.

> +		pages = ERR_PTR(-EAGAI >   	} else {
> -		pages = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
> -		active = !IS_ERR(pages);
> +		if (pinned < num_pages)
> +			pages = __i915_gem_userptr_get_pages_schedule(obj);
> +		else
> +			pages = __i915_gem_userptr_alloc_pages(obj,
> +							       pvec, num_pages);
> +		if (IS_ERR(pages) && pages != ERR_PTR(-EAGAIN))
> +			__i915_gem_userptr_set_active(obj, false);
>   	}
> -	if (active)
> -		__i915_gem_userptr_set_active(obj, true);
> +	up_read(&mm->mmap_sem);
>   
>   	if (IS_ERR(pages))
>   		release_pages(pvec, pinned);
> 

Regards,

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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v6] drm/i915/userptr: Probe vma range before gup
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (13 preceding siblings ...)
  2017-12-15 18:09 ` ✓ Fi.CI.IGT: " Patchwork
@ 2018-02-08 18:02 ` Chris Wilson
  2018-02-09  9:23   ` [PATCH v7] " Chris Wilson
  2018-02-08 18:48 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev6) Patchwork
                   ` (4 subsequent siblings)
  19 siblings, 1 reply; 25+ messages in thread
From: Chris Wilson @ 2018-02-08 18:02 UTC (permalink / raw)
  To: intel-gfx

We want to exclude any GGTT objects from being present on our internal
lists to avoid the deadlock we may run into with our requirement for
struct_mutex during invalidate. However, if the gup_fast fails, we put
the userptr onto the workqueue and mark it as active, so that we
remember to serialise the worker upon mmu_invalidate.

v2: Hold mmap_sem to prevent modifications to the mm while we probe and
add ourselves to the interval-tree for notificiation.
v3: Rely on mmap_sem for a simpler patch.
v4: Mark up the mmap_sem nesting
v5: Don't deactivate on -EAGAIN as that means the worker is queued
v6: Fight the indentation and chained if-else error handling

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 114 +++++++++++++++++++++-----------
 1 file changed, 76 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index 1f9d24021cbb..8286fd15e910 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -411,7 +411,7 @@ struct get_pages_work {
 	struct task_struct *task;
 };
 
-static struct sg_table *
+static int
 __i915_gem_userptr_alloc_pages(struct drm_i915_gem_object *obj,
 			       struct page **pvec, int num_pages)
 {
@@ -422,7 +422,7 @@ __i915_gem_userptr_alloc_pages(struct drm_i915_gem_object *obj,
 
 	st = kmalloc(sizeof(*st), GFP_KERNEL);
 	if (!st)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 alloc_table:
 	ret = __sg_alloc_table_from_pages(st, pvec, num_pages,
@@ -431,7 +431,7 @@ __i915_gem_userptr_alloc_pages(struct drm_i915_gem_object *obj,
 					  GFP_KERNEL);
 	if (ret) {
 		kfree(st);
-		return ERR_PTR(ret);
+		return ret;
 	}
 
 	ret = i915_gem_gtt_prepare_pages(obj, st);
@@ -444,14 +444,14 @@ __i915_gem_userptr_alloc_pages(struct drm_i915_gem_object *obj,
 		}
 
 		kfree(st);
-		return ERR_PTR(ret);
+		return ret;
 	}
 
 	sg_page_sizes = i915_sg_page_sizes(st->sgl);
 
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 
-	return st;
+	return 0;
 }
 
 static int
@@ -532,19 +532,14 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
 
 	mutex_lock(&obj->mm.lock);
 	if (obj->userptr.work == &work->work) {
-		struct sg_table *pages = ERR_PTR(ret);
-
 		if (pinned == npages) {
-			pages = __i915_gem_userptr_alloc_pages(obj, pvec,
-							       npages);
-			if (!IS_ERR(pages)) {
+			ret = __i915_gem_userptr_alloc_pages(obj, pvec, npages);
+			if (!ret)
 				pinned = 0;
-				pages = NULL;
-			}
 		}
 
-		obj->userptr.work = ERR_CAST(pages);
-		if (IS_ERR(pages))
+		obj->userptr.work = ERR_PTR(ret);
+		if (ret)
 			__i915_gem_userptr_set_active(obj, false);
 	}
 	mutex_unlock(&obj->mm.lock);
@@ -557,7 +552,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
 	kfree(work);
 }
 
-static struct sg_table *
+static int
 __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 {
 	struct get_pages_work *work;
@@ -583,7 +578,7 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	 */
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
 	if (work == NULL)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	obj->userptr.work = &work->work;
 
@@ -595,7 +590,38 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	INIT_WORK(&work->work, __i915_gem_userptr_get_pages_worker);
 	queue_work(to_i915(obj->base.dev)->mm.userptr_wq, &work->work);
 
-	return ERR_PTR(-EAGAIN);
+	return -EAGAIN;
+}
+
+static int
+probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
+{
+	const unsigned long end = addr + len;
+	struct vm_area_struct *vma;
+	int ret = -EFAULT;
+
+	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
+		if (vma->vm_start > addr)
+			break;
+
+		/*
+		 * Exclude any VMA that is backed only by struct_page, i.e.
+		 * IO regions that include our own GGTT mmaps. We cannot handle
+		 * such ranges, as we may encounter deadlocks around our
+		 * struct_mutex on mmu_invalidate_range.
+		 */
+		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
+			break;
+
+		if (vma->vm_end >= end) {
+			ret = 0;
+			break;
+		}
+
+		addr = vma->vm_end;
+	}
+
+	return ret;
 }
 
 static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
@@ -603,9 +629,7 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 	const int num_pages = obj->base.size >> PAGE_SHIFT;
 	struct mm_struct *mm = obj->userptr.mm->mm;
 	struct page **pvec;
-	struct sg_table *pages;
-	bool active;
-	int pinned;
+	int pinned, err;
 
 	/* If userspace should engineer that these pages are replaced in
 	 * the vma between us binding this page into the GTT and completion
@@ -634,38 +658,52 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 
 	pvec = NULL;
 	pinned = 0;
-
 	if (mm == current->mm) {
 		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
 				      GFP_KERNEL |
 				      __GFP_NORETRY |
 				      __GFP_NOWARN);
-		if (pvec) /* defer to worker if malloc fails */
+		if (pvec) { /* defer to worker if malloc fails */
 			pinned = __get_user_pages_fast(obj->userptr.ptr,
 						       num_pages,
 						       !obj->userptr.read_only,
 						       pvec);
+			if (pinned < 0) {
+				err = pinned;
+				goto out_pvec;
+			}
+		}
 	}
 
-	active = false;
-	if (pinned < 0) {
-		pages = ERR_PTR(pinned);
-		pinned = 0;
-	} else if (pinned < num_pages) {
-		pages = __i915_gem_userptr_get_pages_schedule(obj);
-		active = pages == ERR_PTR(-EAGAIN);
-	} else {
-		pages = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
-		active = !IS_ERR(pages);
+	/* lockdep doesn't yet automatically allow nesting of readers */
+	down_read_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);
+
+	if (pinned < num_pages &&
+	    probe_range(mm, obj->userptr.ptr, obj->base.size)) {
+		err = -EFAULT;
+		goto err_pinned;
 	}
-	if (active)
-		__i915_gem_userptr_set_active(obj, true);
 
-	if (IS_ERR(pages))
-		release_pages(pvec, pinned);
-	kvfree(pvec);
+	err = __i915_gem_userptr_set_active(obj, true);
+	if (err)
+		goto err_pinned;
 
-	return PTR_ERR_OR_ZERO(pages);
+	if (pinned < num_pages)
+		err = __i915_gem_userptr_get_pages_schedule(obj);
+	else
+		err = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
+	if (err != -EAGAIN) {
+		__i915_gem_userptr_set_active(obj, false);
+		goto err_pinned;
+	}
+
+	pinned = 0;
+err_pinned:
+	up_read(&mm->mmap_sem);
+	release_pages(pvec, pinned);
+out_pvec:
+	kvfree(pvec);
+	return err;
 }
 
 static void
-- 
2.16.1

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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev6)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (14 preceding siblings ...)
  2018-02-08 18:02 ` [PATCH v6] drm/i915/userptr: Probe vma range before gup Chris Wilson
@ 2018-02-08 18:48 ` Patchwork
  2018-02-09  4:02 ` ✗ Fi.CI.IGT: failure " Patchwork
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2018-02-08 18:48 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev6)
URL   : https://patchwork.freedesktop.org/series/35394/
State : success

== Summary ==

Series 35394v6 drm/i915/userptr: Probe vma range before gup
https://patchwork.freedesktop.org/api/1.0/series/35394/revisions/6/mbox/

Test debugfs_test:
        Subgroup read_all_entries:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:418s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:426s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:374s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:493s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:285s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:481s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:486s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:466s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:455s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:565s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:581s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:416s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:512s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:388s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:411s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:463s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:419s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:456s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:494s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:452s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:502s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:606s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:430s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:510s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:524s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:484s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:485s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:413s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:430s
fi-snb-2520m     total:3    pass:2    dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:403s
Blacklisted hosts:
fi-glk-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:468s
fi-gdg-551 failed to collect. IGT log at Patchwork_7960/fi-gdg-551/run0.log

a326a34b0b8db9854fee49eafb526a12b6bc89d6 drm-tip: 2018y-02m-08d-17h-29m-20s UTC integration manifest
ae3f7f35be23 drm/i915/userptr: Probe vma range before gup

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7960/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* ✗ Fi.CI.IGT: failure for drm/i915/userptr: Probe vma range before gup (rev6)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (15 preceding siblings ...)
  2018-02-08 18:48 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev6) Patchwork
@ 2018-02-09  4:02 ` Patchwork
  2018-02-09 14:06 ` ✗ Fi.CI.BAT: failure for drm/i915/userptr: Probe vma range before gup (rev7) Patchwork
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2018-02-09  4:02 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev6)
URL   : https://patchwork.freedesktop.org/series/35394/
State : failure

== Summary ==

Test gem_userptr_blits:
        Subgroup coherency-sync:
                pass       -> DMESG-WARN (shard-snb)
        Subgroup unsync-unmap-after-close:
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup dmabuf-sync:
                pass       -> DMESG-FAIL (shard-snb)
                pass       -> DMESG-FAIL (shard-hsw)
                pass       -> INCOMPLETE (shard-apl)
        Subgroup invalid-gtt-mapping:
                pass       -> INCOMPLETE (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup sync-unmap-after-close:
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup sync-unmap-cycles:
                pass       -> DMESG-FAIL (shard-snb)
                pass       -> FAIL       (shard-apl)
        Subgroup unsync-unmap-cycles:
                pass       -> INCOMPLETE (shard-snb)
                pass       -> INCOMPLETE (shard-apl)
        Subgroup sync-unmap:
                pass       -> DMESG-FAIL (shard-hsw)
                pass       -> FAIL       (shard-apl)
        Subgroup unsync-unmap:
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup map-fixed-invalidate-overlap-busy-gup:
                pass       -> DMESG-WARN (shard-snb)
                pass       -> DMESG-WARN (shard-hsw)
        Subgroup dmabuf-unsync:
                pass       -> DMESG-FAIL (shard-snb)
                pass       -> FAIL       (shard-hsw)
Test kms_cursor_legacy:
        Subgroup pipe-e-torture-bo:
                skip       -> INCOMPLETE (shard-apl)
Test gem_exec_blt:
        Subgroup normal-max:
                pass       -> DMESG-WARN (shard-hsw)
Test kms_cursor_crc:
        Subgroup cursor-64x64-suspend:
                skip       -> PASS       (shard-snb) fdo#102365 +1
        Subgroup cursor-64x64-offscreen:
                skip       -> PASS       (shard-apl)
Test gem_eio:
        Subgroup in-flight:
                fail       -> PASS       (shard-hsw) fdo#104676
Test kms_flip:
        Subgroup 2x-plain-flip-fb-recreate-interruptible:
                fail       -> PASS       (shard-hsw)
Test kms_frontbuffer_tracking:
        Subgroup fbc-1p-primscrn-cur-indfb-draw-blt:
                pass       -> INCOMPLETE (shard-hsw) fdo#103167
Test gem_pwrite:
        Subgroup big-gtt-forwards:
                pass       -> INCOMPLETE (shard-snb)
                pass       -> INCOMPLETE (shard-hsw)
Test kms_vblank:
        Subgroup pipe-a-query-idle:
                pass       -> INCOMPLETE (shard-snb)

fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#104676 https://bugs.freedesktop.org/show_bug.cgi?id=104676
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167

shard-apl        total:3100 pass:1592 dwarn:1   dfail:0   fail:22  skip:1481 time:10788s
shard-hsw        total:3182 pass:1607 dwarn:7   dfail:3   fail:11  skip:1552 time:10254s
shard-snb        total:3118 pass:1204 dwarn:3   dfail:3   fail:9   skip:1895 time:5751s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7960/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v7] drm/i915/userptr: Probe vma range before gup
  2018-02-08 18:02 ` [PATCH v6] drm/i915/userptr: Probe vma range before gup Chris Wilson
@ 2018-02-09  9:23   ` Chris Wilson
  0 siblings, 0 replies; 25+ messages in thread
From: Chris Wilson @ 2018-02-09  9:23 UTC (permalink / raw)
  To: intel-gfx

We want to exclude any GGTT objects from being present on our internal
lists to avoid the deadlock we may run into with our requirement for
struct_mutex during invalidate. However, if the gup_fast fails, we put
the userptr onto the workqueue and mark it as active, so that we
remember to serialise the worker upon mmu_invalidate.

v2: Hold mmap_sem to prevent modifications to the mm while we probe and
add ourselves to the interval-tree for notificiation.
v3: Rely on mmap_sem for a simpler patch.
v4: Mark up the mmap_sem nesting
v5: Don't deactivate on -EAGAIN as that means the worker is queued
v6: Fight the indentation and chained if-else error handling
v7: Fight again.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 162 ++++++++++++++++++++++----------
 1 file changed, 110 insertions(+), 52 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index 1f9d24021cbb..a504746230d1 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -411,7 +411,7 @@ struct get_pages_work {
 	struct task_struct *task;
 };
 
-static struct sg_table *
+static int
 __i915_gem_userptr_alloc_pages(struct drm_i915_gem_object *obj,
 			       struct page **pvec, int num_pages)
 {
@@ -422,7 +422,7 @@ __i915_gem_userptr_alloc_pages(struct drm_i915_gem_object *obj,
 
 	st = kmalloc(sizeof(*st), GFP_KERNEL);
 	if (!st)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 alloc_table:
 	ret = __sg_alloc_table_from_pages(st, pvec, num_pages,
@@ -431,7 +431,7 @@ __i915_gem_userptr_alloc_pages(struct drm_i915_gem_object *obj,
 					  GFP_KERNEL);
 	if (ret) {
 		kfree(st);
-		return ERR_PTR(ret);
+		return ret;
 	}
 
 	ret = i915_gem_gtt_prepare_pages(obj, st);
@@ -444,14 +444,14 @@ __i915_gem_userptr_alloc_pages(struct drm_i915_gem_object *obj,
 		}
 
 		kfree(st);
-		return ERR_PTR(ret);
+		return ret;
 	}
 
 	sg_page_sizes = i915_sg_page_sizes(st->sgl);
 
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 
-	return st;
+	return 0;
 }
 
 static int
@@ -532,19 +532,14 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
 
 	mutex_lock(&obj->mm.lock);
 	if (obj->userptr.work == &work->work) {
-		struct sg_table *pages = ERR_PTR(ret);
-
 		if (pinned == npages) {
-			pages = __i915_gem_userptr_alloc_pages(obj, pvec,
-							       npages);
-			if (!IS_ERR(pages)) {
+			ret = __i915_gem_userptr_alloc_pages(obj, pvec, npages);
+			if (!ret)
 				pinned = 0;
-				pages = NULL;
-			}
 		}
 
-		obj->userptr.work = ERR_CAST(pages);
-		if (IS_ERR(pages))
+		obj->userptr.work = ERR_PTR(ret);
+		if (ret)
 			__i915_gem_userptr_set_active(obj, false);
 	}
 	mutex_unlock(&obj->mm.lock);
@@ -557,7 +552,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
 	kfree(work);
 }
 
-static struct sg_table *
+static int
 __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 {
 	struct get_pages_work *work;
@@ -583,7 +578,7 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	 */
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
 	if (work == NULL)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	obj->userptr.work = &work->work;
 
@@ -595,19 +590,91 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 	INIT_WORK(&work->work, __i915_gem_userptr_get_pages_worker);
 	queue_work(to_i915(obj->base.dev)->mm.userptr_wq, &work->work);
 
-	return ERR_PTR(-EAGAIN);
+	return -EAGAIN;
 }
 
-static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
+static int
+probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
+{
+	const unsigned long end = addr + len;
+	struct vm_area_struct *vma;
+	int ret = -EFAULT;
+
+	for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
+		if (vma->vm_start > addr)
+			break;
+
+		/*
+		 * Exclude any VMA that is backed only by struct_page, i.e.
+		 * IO regions that include our own GGTT mmaps. We cannot handle
+		 * such ranges, as we may encounter deadlocks around our
+		 * struct_mutex on mmu_invalidate_range.
+		 */
+		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
+			break;
+
+		if (vma->vm_end >= end) {
+			ret = 0;
+			break;
+		}
+
+		addr = vma->vm_end;
+	}
+
+	return ret;
+}
+
+static int try_fast_gup(struct drm_i915_gem_object *obj)
 {
 	const int num_pages = obj->base.size >> PAGE_SHIFT;
-	struct mm_struct *mm = obj->userptr.mm->mm;
 	struct page **pvec;
-	struct sg_table *pages;
-	bool active;
-	int pinned;
+	int pinned, err;
+
+	pvec = kvmalloc_array(num_pages, sizeof(struct page *),
+			      GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
+	if (!pvec) /* defer to worker if malloc fails */
+		return -ENOMEM;
 
-	/* If userspace should engineer that these pages are replaced in
+	pinned = __get_user_pages_fast(obj->userptr.ptr,
+				       num_pages,
+				       !obj->userptr.read_only,
+				       pvec);
+	if (pinned < 0) {
+		err = pinned;
+		pinned = 0;
+		goto out_pvec;
+	}
+
+	if (pinned < num_pages) {
+		err = -EFAULT;
+		goto out_pinned;
+	}
+
+	err = __i915_gem_userptr_set_active(obj, true);
+	if (err)
+		goto out_pinned;
+
+	err = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
+	if (err) {
+		__i915_gem_userptr_set_active(obj, false);
+		goto out_pinned;
+	}
+
+	pinned = 0;
+out_pinned:
+	release_pages(pvec, pinned);
+out_pvec:
+	kvfree(pvec);
+	return err;
+}
+
+static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
+{
+	struct mm_struct *mm = obj->userptr.mm->mm;
+	int err;
+
+	/*
+	 * If userspace should engineer that these pages are replaced in
 	 * the vma between us binding this page into the GTT and completion
 	 * of rendering... Their loss. If they change the mapping of their
 	 * pages they need to create a new bo to point to the new vma.
@@ -632,40 +699,31 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
 			return -EAGAIN;
 	}
 
-	pvec = NULL;
-	pinned = 0;
-
 	if (mm == current->mm) {
-		pvec = kvmalloc_array(num_pages, sizeof(struct page *),
-				      GFP_KERNEL |
-				      __GFP_NORETRY |
-				      __GFP_NOWARN);
-		if (pvec) /* defer to worker if malloc fails */
-			pinned = __get_user_pages_fast(obj->userptr.ptr,
-						       num_pages,
-						       !obj->userptr.read_only,
-						       pvec);
+		err = try_fast_gup(obj);
+		if (!err)
+			return 0;
 	}
 
-	active = false;
-	if (pinned < 0) {
-		pages = ERR_PTR(pinned);
-		pinned = 0;
-	} else if (pinned < num_pages) {
-		pages = __i915_gem_userptr_get_pages_schedule(obj);
-		active = pages == ERR_PTR(-EAGAIN);
-	} else {
-		pages = __i915_gem_userptr_alloc_pages(obj, pvec, num_pages);
-		active = !IS_ERR(pages);
-	}
-	if (active)
-		__i915_gem_userptr_set_active(obj, true);
+	/* lockdep doesn't yet automatically allow nesting of readers */
+	down_read_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);
 
-	if (IS_ERR(pages))
-		release_pages(pvec, pinned);
-	kvfree(pvec);
+	err = probe_range(mm, obj->userptr.ptr, obj->base.size);
+	if (err)
+		goto err_unlock;
+
+	err = __i915_gem_userptr_set_active(obj, true);
+	if (err)
+		goto err_unlock;
+
+	err = __i915_gem_userptr_get_pages_schedule(obj);
+	if (err != -EAGAIN)
+		__i915_gem_userptr_set_active(obj, false);
+
+err_unlock:
+	up_read(&mm->mmap_sem);
 
-	return PTR_ERR_OR_ZERO(pages);
+	return err;
 }
 
 static void
-- 
2.16.1

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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* ✗ Fi.CI.BAT: failure for drm/i915/userptr: Probe vma range before gup (rev7)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (16 preceding siblings ...)
  2018-02-09  4:02 ` ✗ Fi.CI.IGT: failure " Patchwork
@ 2018-02-09 14:06 ` Patchwork
  2018-02-09 20:56 ` ✓ Fi.CI.BAT: success " Patchwork
  2018-02-09 22:27 ` ✗ Fi.CI.IGT: warning " Patchwork
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2018-02-09 14:06 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev7)
URL   : https://patchwork.freedesktop.org/series/35394/
State : failure

== Summary ==

Series 35394v7 drm/i915/userptr: Probe vma range before gup
https://patchwork.freedesktop.org/api/1.0/series/35394/revisions/7/mbox/

Test debugfs_test:
        Subgroup read_all_entries:
                pass       -> DMESG-WARN (fi-kbl-7567u)
Test gem_exec_suspend:
        Subgroup basic-s3:
                pass       -> DMESG-WARN (fi-kbl-7567u)
Test gem_mmap_gtt:
        Subgroup basic-small-bo-tiledx:
                fail       -> PASS       (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-a:
                pass       -> DMESG-FAIL (fi-kbl-7567u)
        Subgroup suspend-read-crc-pipe-b:
                incomplete -> PASS       (fi-snb-2520m) fdo#103713
                pass       -> SKIP       (fi-kbl-7567u)
        Subgroup suspend-read-crc-pipe-c:
                pass       -> SKIP       (fi-kbl-7567u)
                pass       -> DMESG-WARN (fi-cnl-y3) fdo#104951
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                pass       -> SKIP       (fi-kbl-7567u)
        Subgroup basic-rte:
                pass       -> SKIP       (fi-kbl-7567u)
Test prime_vgem:
        Subgroup basic-fence-flip:
                pass       -> SKIP       (fi-kbl-7567u)
Test drv_module_reload:
        Subgroup basic-reload:
                pass       -> DMESG-WARN (fi-kbl-7567u)
        Subgroup basic-no-display:
                pass       -> DMESG-WARN (fi-kbl-7567u)
        Subgroup basic-reload-inject:
                pass       -> DMESG-WARN (fi-kbl-7567u)

fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#104951 https://bugs.freedesktop.org/show_bug.cgi?id=104951

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:422s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:423s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:377s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:484s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:286s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:480s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:482s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:469s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:455s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:567s
fi-cnl-y3        total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:575s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:412s
fi-gdg-551       total:288  pass:180  dwarn:0   dfail:0   fail:0   skip:108 time:283s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:510s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:386s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:416s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:457s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:423s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:455s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:495s
fi-kbl-7567u     total:288  pass:257  dwarn:5   dfail:1   fail:0   skip:25  time:415s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:499s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:599s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:430s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:508s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:526s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:490s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:481s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:415s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:429s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:527s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:401s
Blacklisted hosts:
fi-glk-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:468s

6c10ba221576c523e2574d83e75a87cdc7b0bc1e drm-tip: 2018y-02m-08d-19h-13m-44s UTC integration manifest
6e65a5debe66 drm/i915/userptr: Probe vma range before gup

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7963/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev7)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (17 preceding siblings ...)
  2018-02-09 14:06 ` ✗ Fi.CI.BAT: failure for drm/i915/userptr: Probe vma range before gup (rev7) Patchwork
@ 2018-02-09 20:56 ` Patchwork
  2018-02-09 22:27 ` ✗ Fi.CI.IGT: warning " Patchwork
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2018-02-09 20:56 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev7)
URL   : https://patchwork.freedesktop.org/series/35394/
State : success

== Summary ==

Series 35394v7 drm/i915/userptr: Probe vma range before gup
https://patchwork.freedesktop.org/api/1.0/series/35394/revisions/7/mbox/

Test debugfs_test:
        Subgroup read_all_entries:
                incomplete -> PASS       (fi-snb-2520m) fdo#103713
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-cnl-y3) fdo#104951

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#104951 https://bugs.freedesktop.org/show_bug.cgi?id=104951

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:420s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:422s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:377s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:486s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:288s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:481s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:484s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:467s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:454s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:564s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:576s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:414s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:287s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:511s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:389s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:414s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:447s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:418s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:458s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:500s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:496s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:597s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:426s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:506s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:527s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:485s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:497s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:411s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:429s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:518s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:394s
Blacklisted hosts:
fi-glk-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:471s

897018779f8b9aeac758688f0fd21169dfe66fdf drm-tip: 2018y-02m-09d-16h-18m-21s UTC integration manifest
f6b0b419d67a drm/i915/userptr: Probe vma range before gup

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7969/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* ✗ Fi.CI.IGT: warning for drm/i915/userptr: Probe vma range before gup (rev7)
  2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
                   ` (18 preceding siblings ...)
  2018-02-09 20:56 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2018-02-09 22:27 ` Patchwork
  19 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2018-02-09 22:27 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/userptr: Probe vma range before gup (rev7)
URL   : https://patchwork.freedesktop.org/series/35394/
State : warning

== Summary ==

Test kms_setmode:
        Subgroup basic:
                fail       -> PASS       (shard-apl) fdo#99912
Test perf_pmu:
        Subgroup semaphore-wait-idle-bcs0:
                pass       -> FAIL       (shard-apl) fdo#105011
Test kms_cursor_legacy:
        Subgroup cursor-vs-flip-legacy:
                pass       -> FAIL       (shard-apl) fdo#103355
Test drv_suspend:
        Subgroup debugfs-reader:
                pass       -> SKIP       (shard-snb) fdo#102365
Test gem_eio:
        Subgroup in-flight-contexts:
                pass       -> FAIL       (shard-hsw) fdo#104676
Test kms_cursor_crc:
        Subgroup cursor-64x64-offscreen:
                pass       -> SKIP       (shard-apl)

fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#105011 https://bugs.freedesktop.org/show_bug.cgi?id=105011
fdo#103355 https://bugs.freedesktop.org/show_bug.cgi?id=103355
fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#104676 https://bugs.freedesktop.org/show_bug.cgi?id=104676

shard-apl        total:3354 pass:1737 dwarn:1   dfail:0   fail:20  skip:1595 time:12297s
shard-hsw        total:3444 pass:1760 dwarn:1   dfail:0   fail:11  skip:1671 time:11728s
shard-snb        total:3444 pass:1350 dwarn:1   dfail:0   fail:10  skip:2083 time:6566s
Blacklisted hosts:
shard-kbl        total:3380 pass:1865 dwarn:13  dfail:1   fail:21  skip:1479 time:9308s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7969/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2018-02-09 22:27 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-15  9:27 [PATCH] drm/i915/userptr: Probe vma range before gup Chris Wilson
2017-12-15  9:43 ` Tvrtko Ursulin
2017-12-15  9:46 ` Chris Wilson
2017-12-15  9:49 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-12-15  9:53 ` [PATCH v2] " Chris Wilson
2017-12-15 10:06   ` Chris Wilson
2017-12-15 10:09 ` [PATCH v3] " Chris Wilson
2017-12-15 10:49   ` Chris Wilson
2017-12-15 10:33 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev3) Patchwork
2017-12-15 10:38 ` ✗ Fi.CI.IGT: warning for drm/i915/userptr: Probe vma range before gup Patchwork
2017-12-15 11:20 ` [PATCH v4] " Chris Wilson
2017-12-15 11:57 ` ✗ Fi.CI.IGT: failure for drm/i915/userptr: Probe vma range before gup (rev3) Patchwork
2017-12-15 12:22 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev4) Patchwork
2017-12-15 14:33 ` ✗ Fi.CI.IGT: failure " Patchwork
2017-12-15 14:48 ` [PATCH v5] drm/i915/userptr: Probe vma range before gup Chris Wilson
2017-12-18 13:17   ` Tvrtko Ursulin
2017-12-15 15:36 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev5) Patchwork
2017-12-15 18:09 ` ✓ Fi.CI.IGT: " Patchwork
2018-02-08 18:02 ` [PATCH v6] drm/i915/userptr: Probe vma range before gup Chris Wilson
2018-02-09  9:23   ` [PATCH v7] " Chris Wilson
2018-02-08 18:48 ` ✓ Fi.CI.BAT: success for drm/i915/userptr: Probe vma range before gup (rev6) Patchwork
2018-02-09  4:02 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-02-09 14:06 ` ✗ Fi.CI.BAT: failure for drm/i915/userptr: Probe vma range before gup (rev7) Patchwork
2018-02-09 20:56 ` ✓ Fi.CI.BAT: success " Patchwork
2018-02-09 22:27 ` ✗ Fi.CI.IGT: warning " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.