From patchwork Mon Aug 29 16:45:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Barnes X-Patchwork-Id: 1108792 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7TGjukE032176 for ; Mon, 29 Aug 2011 16:46:16 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 729C69F593 for ; Mon, 29 Aug 2011 09:45:56 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from oproxy7-pub.bluehost.com (oproxy7-pub.bluehost.com [67.222.55.9]) by gabe.freedesktop.org (Postfix) with SMTP id 289999EEE5 for ; Mon, 29 Aug 2011 09:45:37 -0700 (PDT) Received: (qmail 11062 invoked by uid 0); 29 Aug 2011 16:45:36 -0000 Received: from unknown (HELO box514.bluehost.com) (74.220.219.114) by oproxy7.bluehost.com with SMTP; 29 Aug 2011 16:45:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuousgeek.org; s=default; h=Content-Transfer-Encoding:Content-Type:Mime-Version:References:In-Reply-To:Message-ID:Subject:Cc:From:Date; bh=vI9hfYStsY4NSSVzX+kMb9N3EGIzS+4ZIAb2txEa4Eo=; b=FwJFE//2z0JD3aqGWiHZEKo77pp4jJM6bjDpLsh9q+B85e5dyjOPurxEMVHZ04AYmJWMQ0A7qsJDugoIGREG394CazTpY/uRnTKIDH7hsuZRor/vK9hf0/EplqvTHGJp; Received: from c-67-161-37-189.hsd1.ca.comcast.net ([67.161.37.189] helo=jbarnes-desktop) by box514.bluehost.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1Qy4xs-0001zu-8z for intel-gfx@lists.freedesktop.org; Mon, 29 Aug 2011 10:45:36 -0600 Date: Mon, 29 Aug 2011 09:45:28 -0700 From: Jesse Barnes Cc: intel-gfx@lists.freedesktop.org Message-ID: <20110829094528.2b176630@jbarnes-desktop> In-Reply-To: <20110829094452.7a5adf03@jbarnes-desktop> References: <20110822110531.57d85c32@jbarnes-desktop> <20110829094452.7a5adf03@jbarnes-desktop> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.22.0; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Identified-User: {10642:box514.bluehost.com:virtuous:virtuousgeek.org} {sentby:smtp auth 67.161.37.189 authed with jbarnes@virtuousgeek.org} Subject: Re: [Intel-gfx] [PATCH] drm/i915: don't set unpin_work if vblank_get fails X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 29 Aug 2011 16:46:16 +0000 (UTC) On Mon, 29 Aug 2011 09:44:52 -0700 Jesse Barnes wrote: > On Mon, 22 Aug 2011 11:05:31 -0700 > Jesse Barnes wrote: > > > This fixes a race where we may try to finish a page flip and decrement > > the refcount even if our vblank_get failed and we ended up with a > > spurious flip pending interrupt. > > > > Fixes https://bugs.freedesktop.org/show_bug.cgi?id=34211. > > > > Signed-off-by: Jesse Barnes > > Updated patch. Though now I've lost track of the outstanding > issues... IIRC we still have another race here, but it's unrelated to > the one in the bug report. With patch... diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 2319f62..9cd523b 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6896,11 +6896,16 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, work->old_fb_obj = intel_fb->obj; INIT_WORK(&work->work, intel_unpin_work_fn); + ret = drm_vblank_get(dev, intel_crtc->pipe); + if (ret) + goto free_work; + /* We borrow the event spin lock for protecting unpin_work */ spin_lock_irqsave(&dev->event_lock, flags); if (intel_crtc->unpin_work) { spin_unlock_irqrestore(&dev->event_lock, flags); kfree(work); + drm_vblank_put(dev, intel_crtc->pipe); DRM_DEBUG_DRIVER("flip queue: crtc already busy\n"); return -EBUSY; @@ -6919,10 +6924,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, crtc->fb = fb; - ret = drm_vblank_get(dev, intel_crtc->pipe); - if (ret) - goto cleanup_objs; - work->pending_flip_obj = obj; work->enable_stall_check = true; @@ -6945,7 +6946,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, cleanup_pending: atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip); -cleanup_objs: drm_gem_object_unreference(&work->old_fb_obj->base); drm_gem_object_unreference(&obj->base); mutex_unlock(&dev->struct_mutex); @@ -6954,6 +6954,8 @@ cleanup_objs: intel_crtc->unpin_work = NULL; spin_unlock_irqrestore(&dev->event_lock, flags); + drm_vblank_put(dev, intel_crtc->pipe); +free_work: kfree(work); return ret;