[Intel-gfx] [PATCH 4/4] drm/i915: Support for pread/pwrite from/to non shmem backed objects

Ankitprasad Sharma ankitprasad.r.sharma at intel.com
Tue Sep 15 03:35:05 PDT 2015


On Tue, 2015-09-15 at 10:54 +0100, Chris Wilson wrote:
> On Tue, Sep 15, 2015 at 02:03:27PM +0530, ankitprasad.r.sharma at intel.com wrote:
> > @@ -1090,17 +1184,17 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
> >  		goto out;
> >  	}
> >  
> > -	/* prime objects have no backing filp to GEM pread/pwrite
> > -	 * pages from.
> > -	 */
> > -	if (!obj->base.filp) {
> > -		ret = -EINVAL;
> > -		goto out;
> > -	}
> > -
> >  	trace_i915_gem_object_pwrite(obj, args->offset, args->size);
> >  
> >  	ret = -EFAULT;
> > +
> > +	/* pwrite for non shmem backed objects */
> > +	if (!obj->base.filp) {
> > +		ret = i915_gem_gtt_pread_pwrite(dev, obj, args->size,
> > +						args->offset, args->data_ptr,
> > +						true);
> > +		goto out;
> > +	}
> 
> There already exists a GTT write path, along with a more correct
> description of its limitations.

Then it would look something like this, making i915_gem_gtt_pwrite_fast
to handle pagefaults for non-shmem backed objects

@@ -831,10 +925,16 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev,
                 * retry in the slow path.
                 */
-         if (fast_user_write(dev_priv->gtt.mappable, page_base,
+            if (obj->base.filp &&
+                 fast_user_write(dev_priv->gtt.mappable, page_base,
                                 page_offset, user_data, page_length)) {
                        ret = -EFAULT;
                        goto out_flush;
+            } else if (slow_user_access(dev_priv->gtt.mappable,
+                                        page_base, page_offset,
+                                       user_data, page_length, true)) {
+                       ret = -EFAULT;
+                       goto out_flush;
             }
 
Thanks
-Ankit




More information about the Intel-gfx mailing list