From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Widawsky Subject: Re: [PATCH] drm/i915: ioctl to query a bo's cache level Date: Thu, 22 Sep 2011 15:36:51 +0000 Message-ID: <20110922153650.GA10332@cloud01> References: <1316632769-2587-1-git-send-email-daniel.vetter@ffwll.ch> <1316656031-11239-1-git-send-email-ben@bwidawsk.net> <1316656031-11239-2-git-send-email-ben@bwidawsk.net> <20110922073512.GC2924@phenom.ffwll.local> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from cloud01.chad-versace.us (184-106-247-128.static.cloud-ips.com [184.106.247.128]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D47A9E912 for ; Thu, 22 Sep 2011 08:33:18 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20110922073512.GC2924@phenom.ffwll.local> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Daniel Vetter Cc: Daniel Vetter , intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Thu, Sep 22, 2011 at 09:35:12AM +0200, Daniel Vetter wrote: > On Wed, Sep 21, 2011 at 06:47:10PM -0700, Ben Widawsky wrote: > > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > > index a546a71..362da16 100644 > > --- a/drivers/gpu/drm/i915/i915_gem.c > > +++ b/drivers/gpu/drm/i915/i915_gem.c > > @@ -3777,6 +3777,29 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj) > > } > > > > int > > +i915_gem_get_cache_type_ioctl(struct drm_device *dev, void *data, > > + struct drm_file *file_priv) > > +{ > > + > > + struct drm_i915_gem_get_cache_type *args = data; > > + struct drm_i915_gem_object *obj; > > + int ret = 0; > > + > > + obj = to_intel_bo(drm_gem_object_lookup(dev, file_priv, args->handle)); > > + if (&obj->base == NULL) { > > + ret = -ENOENT; > > + goto out; > > + } > > + > > + args->cache_level = obj->cache_level; > > Grab struct_mutex around this, obj->cache_level might change over the > lifetime of the bo. Yeah, our locking is a mess, I know ;-) I don't see how a lock by itself helps. The cache_level could change as soon as you release the lock which results in the same problem. Ben