Message ID | 20180531113552.13152-5-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, 2018-05-31 at 12:35 +0100, Chris Wilson wrote: > On gen8 and onwards, we can mark GPU accesses through the ppGTT as being > read-only, that is cause any GPU write onto that page to be discarded > (not triggering a fault). This is all that we need to finally support > the read-only flag for userptr! > > Testcase: igt/gem_userptr_blits/readonly* > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Jon Bloomfield <jon.bloomfield@intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Please add clarification to the commit message that this expands uAPI (by supporting RO userptrs), so Rodrigo will notice to highlight for -next PR. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Regards, Joonas
Quoting Joonas Lahtinen (2018-06-01 11:21:43) > On Thu, 2018-05-31 at 12:35 +0100, Chris Wilson wrote: > > On gen8 and onwards, we can mark GPU accesses through the ppGTT as being > > read-only, that is cause any GPU write onto that page to be discarded > > (not triggering a fault). This is all that we need to finally support > > the read-only flag for userptr! > > > > Testcase: igt/gem_userptr_blits/readonly* > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Jon Bloomfield <jon.bloomfield@intel.com> > > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > > Please add clarification to the commit message that this expands uAPI > (by supporting RO userptrs), so Rodrigo will notice to highlight for > -next PR. Ha, I was playing the "this was already in the uAPI" card, just never implemented so hadn't made it in the uABI. :) Being able to import read-only shm segments (or PROT_READ file mmaps) was always on my wishlist, just at the time the only prospect was special case supporting it for byt (not very appealing). PR material it is then. -Chris
diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c index 854bd51b9478..d4ee8fa4c379 100644 --- a/drivers/gpu/drm/i915/i915_gem_userptr.c +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c @@ -789,10 +789,12 @@ i915_gem_userptr_ioctl(struct drm_device *dev, return -EFAULT; if (args->flags & I915_USERPTR_READ_ONLY) { - /* On almost all of the current hw, we cannot tell the GPU that a - * page is readonly, so this is just a placeholder in the uAPI. + /* + * On almost all of the older hw, we cannot tell the GPU that + * a page is readonly. */ - return -ENODEV; + if (INTEL_GEN(dev_priv) < 8 || !USES_PPGTT(dev_priv)) + return -ENODEV; } obj = i915_gem_object_alloc(dev_priv); @@ -806,7 +808,10 @@ i915_gem_userptr_ioctl(struct drm_device *dev, i915_gem_object_set_cache_coherency(obj, I915_CACHE_LLC); obj->userptr.ptr = args->user_ptr; - obj->userptr.read_only = !!(args->flags & I915_USERPTR_READ_ONLY); + if (args->flags & I915_USERPTR_READ_ONLY) { + obj->userptr.read_only = true; + obj->gt_ro = true; + } /* And keep a pointer to the current->mm for resolving the user pages * at binding. This means that we need to hook into the mmu_notifier
On gen8 and onwards, we can mark GPU accesses through the ppGTT as being read-only, that is cause any GPU write onto that page to be discarded (not triggering a fault). This is all that we need to finally support the read-only flag for userptr! Testcase: igt/gem_userptr_blits/readonly* Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Jon Bloomfield <jon.bloomfield@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> --- drivers/gpu/drm/i915/i915_gem_userptr.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)