Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> writes: > Since a change in cache level is likely to trigger an unbind, avoid > waiting under the mutex by preemptively doing an unlocked wait. > > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > --- > drivers/gpu/drm/i915/i915_gem.c | 29 +++++++++++++++++++---------- > 1 file changed, 19 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > index c1c2765bb8d0..0926c291404c 100644 > --- a/drivers/gpu/drm/i915/i915_gem.c > +++ b/drivers/gpu/drm/i915/i915_gem.c > @@ -3384,7 +3384,7 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data, > struct drm_i915_gem_caching *args = data; > struct drm_i915_gem_object *obj; > enum i915_cache_level level; > - int ret; > + int ret = 0; > > switch (args->caching) { > case I915_CACHING_NONE: > @@ -3409,20 +3409,29 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data, > return -EINVAL; > } > > - ret = i915_mutex_lock_interruptible(dev); > + obj = i915_gem_object_lookup(file, args->handle); > + if (!obj) > + return -ENOENT; > + > + if (obj->cache_level == level) > + goto out; > + > + ret = i915_gem_object_wait(obj, > + I915_WAIT_INTERRUPTIBLE, > + MAX_SCHEDULE_TIMEOUT, > + to_rps_client(file)); > if (ret) > - return ret; > + goto out; > > - obj = i915_gem_object_lookup(file, args->handle); > - if (!obj) { > - ret = -ENOENT; > - goto unlock; > - } Is the intent here that you just make it very likely that the wait in set_cache_level will not trigger? -Mika > + ret = i915_mutex_lock_interruptible(dev); > + if (ret) > + goto out; > > ret = i915_gem_object_set_cache_level(obj, level); > - i915_gem_object_put(obj); > -unlock: > mutex_unlock(&dev->struct_mutex); > + > +out: > + i915_gem_object_put(obj); > return ret; > } > > -- > 2.11.0 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/intel-gfx _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx