[Intel-gfx] [PATCH] drm/i915: Check for get_pages instead of shmem (filp)
Dave Gordon
david.s.gordon at intel.com
Tue Feb 9 11:30:34 UTC 2016
On 09/02/16 00:20, Kristian Høgsberg wrote:
> On Fri, Feb 5, 2016 at 5:48 PM, Ben Widawsky
> <benjamin.widawsky at intel.com> wrote:
>> This behavior of checking for a shmem backed GEM object was introduced here:
>> commit 4c914c0c7c787b8f730128a8cdcca9c50b0784ab
>> Author: Brad Volkin <bradley.d.volkin at intel.com>
>> Date: Tue Feb 18 10:15:45 2014 -0800
>>
>> drm/i915: Refactor shmem pread setup
>>
>> It is possible for an object to not be a shmem backed GEM object (for example
>> userptr objects). An example of how we hit this failure can be found through
>> copy_batch() in the command parser because we allocate a userptr object for the
>> batch which contains privileged instructions. Userptr calls
>> drm_gem_private_object_init() which explicitly sets the filp to none.
>>
>> It is equally feasible to simply remove the check altogether. You'll probably
>> oops with get_pages somewhere, but that's okay IMO because this condition
>> should be a driver bug, and not trigger-able by userspace. On this note, the
>> function name could probably benefit from a change, but whatever.
>>
>> NOTE: I manually retyped this from a test machine. So I haven't even compiled
>> this exact patch.
>>
>> Cc: Chris Wilson <chris at chris-wilson.co.uk>
>> Cc: Kristian Høgsberg <krh at bitplanet.net>
>> Cc: Jordan Justen <jordan.l.justen at intel.com>
>> Signed-off-by: Ben Widawsky <benjamin.widawsky at intel.com>
>> ---
>> drivers/gpu/drm/i915/i915_gem.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
>> index 66b1705..a198928 100644
>> --- a/drivers/gpu/drm/i915/i915_gem.c
>> +++ b/drivers/gpu/drm/i915/i915_gem.c
>> @@ -489,7 +489,7 @@ int i915_gem_obj_prepare_shmem_read(struct drm_i915_gem_object *obj,
>>
>> *needs_clflush = 0;
>>
>> - if (!obj->base.filp)
>> + if (!obj->ops->get_pages)
Don't all subclasses have a get_pages() function?
> Do we want to do what Chris did in
> a2a4f916c2f344d4e596c875dd1e66764afec8b8 (on drm-intel-fixes):
>
> + if (WARN_ON((obj->ops->flags & I915_GEM_OBJECT_HAS_STRUCT_PAGE) == 0))
>
> ?
Yes, I think so; i915_gem_shmem_pread() is going to walk the sglist, so
the object had better have a page array for it to iterate over.
.Dave.
More information about the Intel-gfx
mailing list